I want to exclude several files (*_include.as) in my source project, to generate ASDOC :
<target name="build-asdoc" depends="manifest">
<delete dir="${asdoc.dir}" />
<mkdir dir="${asdoc.dir}" />
<exec executable="${FLEX_HOME}/bin/asdoc.exe" failonerror="false">
<arg line="-doc-sources '${src.dir}'" />
<arg line="-doc-sources '${lib.dir}'" />
<arg line="-external-library-path '${ivy.cache.dir}/org.puremvc.as3/singlecore/swcs'" />
<arg line="-external-library-path '${ivy.cache.dir}/com.keepcore.calendar/KCCalendar/swcs'" />
<arg line="-external-library-path '${ivy.cache.dir}/org.as3commons/as3commons-lang/swcs'" />
<arg line="-main-title '${asdoc.mainTitle}'" />
<arg line="-window-title '${asdoc.windowTitle}'" />
<arg line="-output '${asdoc.dir}'" />
<arg line="-footer '${asdoc.footer}'" />
<arg line="-exclude-sources ?????" />
</exec>
</target>
Thank you very much,
Regards,
Anthony
Use a fileset and a path convert :
<fileset dir="${src.dir}" id="src.files">
<include name="**/*.cpp"/>
</fileset>
<pathconvert pathsep="," property="excluded.src.files" refid="src.files"/>
Now property ${excluded.src.files} will have your files separated by a space, you can add your own separator etc. according to your program input argument. Then you just pass this with your -exlucde-sources arg to your program and that's it.
Related
How to apply pack200 using build file?
Please specify your answer where I am missing.
This is my code:
<target name="pack200">
<apply executable="pack200" parallel="false" dest="${build.dir}">
<arg value="--modification-time=latest"/>
<arg value="--deflate-hint=true"/>
<arg value="--segment-limit=-1"/>
<targetfile/>
<srcfile/>
<fileset dir="${build.dir}" includes="*/.jar" />
<mapper type="glob" from="D:/*" to="D:/*.pack.gz" />
</apply>
</target>
we have a problem on our Zend Server during the deployment of an application.
We've set up a virtual host on our Zend Server called "dev.application-7.de".
We are trying to deploy our Zend Framework 2 project over Jenkins to this virtual host. Usually this works well.
But we got the following error in 3 out of 170 builds:
deploy:
[exec] ======================================================================
[exec] The application has thrown an exception!
[exec] ======================================================================
[exec] ZendServerWebApi\Model\Exception\ApiException
[exec] Invalid userAppName parameter: Application name 'application-7' already exists
[exec] 2015-03-13T11:35:12+01:00 ERR (3): Invalid userAppName parameter: Application name 'application-7' already exists<zendServerAPIResponse xmlns="http://www.zend.com/server/api/1.9">
[exec] <requestData>
[exec] <apiKeyName><![CDATA[ZendStudio]]></apiKeyName>
[exec] <method>applicationDeploy</method>
[exec] </requestData>
[exec] <errorData>
[exec] <errorCode>applicationConflict</errorCode>
[exec] <errorMessage><![CDATA[Invalid userAppName parameter: Application name 'application-7' already exists]]></errorMessage>
[exec] </errorData></zendServerAPIResponse>
To fix this problem, we deleted the virtual host and recreated it with the same config mentioned below.
Is there another way to fix the problem?
Further Information
Zend Server Version:
Version 8.0.2, Developer Standard Edition, Development profile
OS Version:
Ubuntu 14.04.1 LTS
Jenkins Version:
1.599
Information about the Virtual-Host:
Type: Zend Server defined
Created at: 27/Feb/2015 8:18:23
Document Root: /usr/local/zend/var/apps/https/dev.application-7.de/443/1.0.0_177/public/
Security: SSL enabled
Certificate File Path /etc/apache2/ssl/dev.application-7.de.crt
Key File Path /etc/apache2/ssl/dev.application-7.de.key
Chain File Path /etc/apache2/ssl/dev.application-7.de.csr
Virtual-Hosts Config:
<VirtualHost *:443>
SetEnv "APP_ENV" "dev"
DocumentRoot "/usr/local/zend/var/apps/https/dev.application-7.de/443/1.0.0_177/public/"
<Directory "/usr/local/zend/var/apps/https/dev.application-7.de/443/1.0.0_177/public/">
Options +Indexes +FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile "/etc/apache2/ssl/dev.application-7.de.crt"
SSLCertificateKeyFile "/etc/apache2/ssl/dev.application-7.de.key"
SSLCertificateChainFile "/etc/apache2/ssl/dev.application-7.de.csr"
ServerName dev.application-7.de:443
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# include the folder containing the vhost aliases for zend server deployment
IncludeOptional "/usr/local/zend/etc/sites.d/https/dev.application-7.de/443/*.conf"
</VirtualHost>
Ant Build File:
<?xml version="1.0" encoding="UTF-8"?>
<project name="application-7-de-2" default="build">
<!-- By default, we assume all tools to be on the $PATH -->
<!-- <property name="toolsdir" value=""/> -->
<!-- Uncomment the following when the tools are in ${basedir}/vendor/bin -->
<!-- <property name="toolsdir" value="${basedir}/vendor/bin/"/> -->
<!-- Uncomment the following when the tools are in a custom path -->
<property name="baseuri" value="https://dev.application-7.de:443"/>
<property name="appname" value="application-7-de"/>
<property name="defaultserver" value="false"/>
<property name="toolsdir" value="/usr/local/zend/bin/"/>
<property name="params" value="APP_ENV=dev"/>
<property name="host" value="http://our-zend-server.de:10081"/>
<property name="key" value="ZendStudio"/>
<property name="secret" value="OUR_SECRET"/>
<target name="build" depends="prepare,composer,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,phpunit,phpdox,zpk,deploy" description=""/>
<target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit,phpdox" description=""/>
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="phpcpd-ci"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc-ci"/>
</parallel>
</target>
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
<delete dir="${basedir}/build/phpdox"/>
<property name="clean.done" value="true"/>
</target>
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
<mkdir dir="${basedir}/build/phpdox"/>
<property name="prepare.done" value="true"/>
</target>
<target name="composer" depends="prepare" description="Update dependencies">
<exec executable="${toolsdir}composer" failonerror="true">
<arg value="update"/>
<arg value="--working-dir"/>
<arg path="${basedir}"/>
</exec>
</target>
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/module">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<exec executable="${toolsdir}phploc">
<arg value="--count-tests" />
<arg path="${basedir}/module" />
<arg path="${basedir}/tests" />
</exec>
</target>
<target name="phploc-ci" depends="prepare" description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phploc">
<arg value="--count-tests" />
<arg value="--log-csv" />
<arg path="${basedir}/build/logs/phploc.csv" />
<arg value="--log-xml" />
<arg path="${basedir}/build/logs/phploc.xml" />
<arg path="${basedir}/module" />
<arg path="${basedir}/tests" />
</exec>
</target>
<target name="pdepend" depends="prepare" description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}pdepend">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpmd" description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpmd">
<arg path="${basedir}/module" />
<arg value="text" />
<arg path="${basedir}/build/phpmd.xml" />
</exec>
</target>
<target name="phpmd-ci" depends="prepare" description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpmd">
<arg path="${basedir}/module" />
<arg value="xml" />
<arg path="${basedir}/build/phpmd.xml" />
<arg value="--reportfile" />
<arg path="${basedir}/build/logs/pmd.xml" />
</exec>
</target>
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpcs">
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="${basedir}/module" />
<arg path="${basedir}/tests" />
</exec>
</target>
<target name="phpcs-ci" depends="prepare" description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${toolsdir}phpcpd">
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpcpd-ci" depends="prepare" description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
<exec executable="${toolsdir}phpcpd">
<arg value="--log-pmd" />
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/module" />
</exec>
</target>
<target name="phpunit" depends="prepare" description="Run unit tests with PHPUnit">
<exec executable="${toolsdir}phpunit" failonerror="true">
<arg value="--log-junit"/>
<arg value="build/logs/junit.xml"/>
<arg value="--configuration"/>
<arg path="${basedir}/tests/phpunit.xml"/>
</exec>
</target>
<target name="phpdox" depends="phploc-ci,phpcs-ci,phpmd-ci" description="Generate project documentation using phpDox">
<exec executable="${toolsdir}phpdox" dir="${basedir}/build"/>
</target>
<target name="zpk" depends="phpdox">
<exec executable="${toolsdir}zs-client" failonerror="true">
<arg value="packZpk"/>
<arg value="--folder=${basedir}"/>
<arg value="--destination=${basedir}"/>
<arg value="--name=application.zpk"/>
</exec>
</target>
<target name="deploy" depends="zpk">
<exec executable="${toolsdir}zs-client" failonerror="true">
<arg value="installApp"/>
<arg value="--baseUri=${baseuri}"/>
<arg value="--userAppName=${appname}"/>
<arg value="--defaultServer=${defaultserver}"/>
<arg value="--userParams=${params}"/>
<arg value="--zpk=${basedir}/application.zpk"/>
<arg value="--zsurl=${host}"/>
<arg value="--zskey=${key}"/>
<arg value="--zssecret=${secret}"/>
</exec>
</target>
</project>
I have set up my first CI environment with Jenkins and Phing and it is mostly running perfectly, though I have a few hiccups I can't resolve. I am constantly having trouble in determining how to reference directories within various parts of my build process, appreciate any thoughts on the below:
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="dev" basedir=".">
<property name="baseDir" value="." />
<property name="resourceDir" value="${baseDir}/resources" />
<property name="srcDir" value="${baseDir}/src" />
<property name="outputDir" value="${baseDir}/build" />
<property name="logDir" value="${baseDir}/build/logs" />
<property name="phpmdRulesets" value="${resourceDir}/phpmd/rulesets" />
<property name="devServer" value="C:\Apache24\htdocs\myProject.com" />
<target name="init">
<mkdir dir="${outputDir}" />
<mkdir dir="${logDir}" />
</target>
<target name="clean">
<delete dir="${devServer}" includeemptydirs="true" verbose="true" failonerror="true" />
<mkdir dir="${devServer}" />
</target>
<target name="test">
<echo msg="Running unit tests" />
<exec executable="phpunit" checkreturn="true">
<arg value="--log-junit=${logDir}/PHPUnit.xml" />
<arg value="--verbose" />
<arg value="--debug" />
<arg value="--coverage-clover=${logDir}/clover.xml" />
<arg path="${baseDir}" />
</exec>
</target>
<target name="build" depends="phpcs, phpmd, phpcpd, phpDox">
<echo msg="Running build" />
<echo msg="Copying files to build directory..." />
<copy todir="${outputDir}">
<fileset dir="${baseDir}">
<include name="**/src/**" />
<include name="**/resources/**" />
</fileset>
</copy>
</target>
<target name="phpcs">
<echo msg="Running phpcs" />
<exec executable="phpcs">
<arg value="--report=checkstyle" />
<arg value="--ignore=${srcDir}/php/Test/*,${srcDir}/php/lib/*" />
<arg value="--report-file=${logDir}/checkstyle.xml" />
<arg path="${srcDir}" />
</exec>
</target>
<target name="phpmd">
<echo msg="Running phpmd" />
<exec executable="phpmd">
<arg path="${srcDir}" />
<arg value="xml" />
<arg value="${phpmdRulesets}/codesize.xml,${phpmdRulesets}/unusedcode.xml,${phpmdRulesets}/naming.xml,${phpmdRulesets}/design.xml" />
<arg value="--reportfile ${logDir}/messdetector.xml" />
<arg value="--exclude ${srcDir}/php/Test/,${srcDir}/php/lib/" />
</exec>
</target>
<target name="phpcpd">
<echo msg="Running phpcpd" />
<exec executable="phpcpd">
<arg value="--log-pmd=${logDir}/phpcpd.xml" />
<arg value="-vvv" />
<arg value="--exclude=${srcDir}/php/Test/,${srcDir}/php/lib/" />
<arg path="${srcDir}" />
</exec>
</target>
<target name="phpDox">
<echo msg="Running phpDox" />
<exec executable="phpdox">
<arg value="${resourceDir}" />
</exec>
</target>
<target name="dev" depends="init, clean, test, build">
<echo msg="Running dev target" />
<copy file="${outputDir}/src/php/index.php" tofile="${devServer}/index.php" />
<copy todir="${devServer}/php">
<fileset dir="${outputDir}/src/php">
<include name="**" />
<exclude name="**/index.php" />
</fileset>
</copy>
<copy todir="${devServer}/api">
<fileset dir="${outputDir}/api/html">
<include name="**" />
</fileset>
</copy>
<copy file="${outputDir}/src/php/lib/phpLogin/index.php" tofile="${devServer}/php/lib/phpLogin/index.php" />
</target>
</project>
Issue 1: phpmd won't output the reportfile yet there are no errors reported in the Jenkins log. Instead it is logging the entire xml to the stdout and reporting it in the Jenkins logs.
myProject > phpmd:
[echo] Running phpmd
Property ${srcDir} => ./src
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${phpmdRulesets} => ./resources/phpmd/rulesets
Property ${logDir} => ./build/logs
Property ${srcDir} => ./src
Property ${srcDir} => ./src
[exec] Executing command: phpmd ./src xml ./resources/phpmd/rulesets/codesize.xml,./resources/phpmd/rulesets/unusedcode.xml,./resources/phpmd/rulesets/naming.xml,./resources/phpmd/rulesets/design.xml "--reportfile ./build/logs/messdetector.xml" "--exclude ./src/php/Test/,./src/php/lib/" 2>&1
[exec] <?xml version="1.0" encoding="UTF-8" ?>
...
Issue 2: I am unable to get phpDox to exclude certain directories within my source code. Below is my phpdox.xml.
<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://phpdox.de/config">
<project name="myProject.com" source="src/php" workdir="build/api/xml">
<collector backend="parser" publiconly="false">
<include mask="*.php" />
<exclude mask="/lib/**" />
</collector>
<generator output="build/api">
<build engine="html" output="html"/>
</generator>
</project>
</phpdox>
Does anyone know the correct exclude mask I can use please? My file structure is:
myProject.com
/build.xml
/phpdox.xml
/src
/php
/lib
Both issues resolved.
Issue 1: Changed the phpmd task to only use arg values and not arg path. Fixed below:
<target name="phpmd">
<echo msg="Running phpmd" />
<exec executable="phpmd">
<arg value="${dir.src}" />
<arg value="xml" />
<arg value="${dir.phpmdRulesets}/codesize.xml,${dir.phpmdRulesets}/unusedcode.xml,${dir.phpmdRulesets}/naming.xml,${dir.phpmdRulesets}/design.xml" />
<arg value="--reportfile" />
<arg value="${dir.logs}/messdetector.xml" />
<arg value="--exclude"/>
<arg value="test,lib" />
</exec>
</target>
Issue 2: Finally got the exclude masks to work. Fixed xml below:
<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://phpdox.de/config">
<project name="myProject.com" source="src/app" workdir="build/api/xml">
<collector backend="parser" publiconly="false">
<include mask="*.php" />
<exclude mask="**/*lib*" />
<exclude mask="**/*test*" />
</collector>
<generator output="build/api">
<build engine="html" output="html"/>
</generator>
</project>
</phpdox>
I'm used a script ANT, with MXMLC task to build my AIR application. The generation is oK (.swf is generated). But the xxx-app.xml is not generated too ?
<mxmlc
file="${src.dir}/${trinity.project}.mxml"
output="${release.dir}/${trinity-client}.swf"
locale="fr_FR"
static-rsls="true"
accessible="true"
configname="air"
debug="false"
failonerror="true"
fork="true"
optimize="true"
maxmemory="512m">
<load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${src.dir}"/>
<use-network>true</use-network>
<external-library-path file="${FLEX_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
<library-path dir="${ivy.cache.dir}" append="true">
<include name="${puremvc.lib}"/>
<include name="${kccalendar.lib}"/>
<include name="${as3commons.lib}"/>
</library-path>
</mxmlc>
Have you got a solution ?
Thank you very much,
Anthony
You need to call adt in the sdk folder, to make a .air package.
eg:
<target name="execute.air">
<condition property="adt.name" value="adt">
<os family="unix" />
</condition>
<condition property="adt.name" value="adt.bat">
<os family="windows" />
</condition>
<exec executable="${FLEX_HOME}/bin/${adt.name}" failonerror="true">
<arg line="-package" />
<arg line="-tsa none" />
<arg line="-storetype pkcs12" />
<arg line="-keystore ${basedir}/keys/${APP_NAME}.p12" />
<arg line="-storepass password" />
<arg line="${DEPLOY_DIR}/${APP_NAME}.air" />
<arg line="${SRC_DIR}/${APP_NAME}-app.xml" />
<arg line="-C ${DEPLOY_DIR} ${APP_NAME}.swf" />
</exec>
</target>
I'm trying to invoke FindBugs from inside Ant. In order to control the amount of memory available to FindBugs, I've chosen not to use the ant-task. The problem I have now is that I want to pass a number of jars on the command-line to FindBugs:
java -jar .../findbugs.jar foo.jar bar.jar fie.jar
However, since these jars actually are Eclipse plugins, I don't know the exact name of the jars so I need a way to use a wildcard to obtain the list. This is what I've come up with:
<target name="findbugs">
<property name="findbugs.home" location="${user.home}/eclipse/findbugs" />
<path id="findbugs.input">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="my.plugins.*.jar" />
</fileset>
</path>
<path id="findbugs.auxinput">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<java jar="${findbugs.home}/lib/findbugs.jar" fork="true">
<jvmarg value="-Xmx1048m" />
<arg value="-textui" />
<arg value="-output" />
<arg value="findbugs.xml" />
<arg value="-xml" />
<arg value="-exclude" />
<arg value="${basedir}/findbugsExclude.xml" />
<arg value="-auxclasspath" />
<arg pathref="findbugs.auxinput"/>
<arg pathref="findbugs.input" />
</java>
</target>
However, the findbugs.input pathref is a comma-separated list of jars, and not space-separated as FindBugs wants it. How do I get the list of jars as a space-separated list?
(Is this perhaps easier to do with the FindBugs ant-task. I can't really tell from the documentation.)
Use pathconvert, like this:
<pathconvert pathsep="," property="findbugs.input.csv" refid="findbugs.input"/>
Implementing in the target that you provided, I changed the reference from <arg pathref="findbugs.input" />
to <arg value="${findbugs.input.csv}" />
<target name="findbugs">
<property name="findbugs.home" location="${user.home}/eclipse/findbugs" />
<path id="findbugs.input">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="my.plugins.*.jar" />
</fileset>
</path>
<pathconvert pathsep="," property="findbugs.input.csv"
refid="findbugs.input"/>
<path id="findbugs.auxinput">
<fileset dir="${testDirectory}/eclipse/plugins">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<echo message="${findbugs.input.csv}" />
<java jar="${findbugs.home}/lib/findbugs.jar" fork="true">
<jvmarg value="-Xmx1048m" />
<arg value="-textui" />
<arg value="-output" />
<arg value="findbugs.xml" />
<arg value="-xml" />
<arg value="-exclude" />
<arg value="${basedir}/findbugsExclude.xml" />
<arg value="-auxclasspath" />
<arg pathref="findbugs.auxinput"/>
<arg value="${findbugs.input.csv}" />
</java>
</target>
Use <pathconvert> to convert the path into the proper format, storing it into a property then use <arg value...> instead of <arg pathref...>
You can control the memory from the ant task:
<findbugs jvmargs="-Xms512m -Xmx512m" ...>
...
</findbugs>