Having directory reference trouble with Jenkins & Phing - jenkins

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>

Related

Read Ant properties file generated by Apache FOP

I am new to Ant. I am trying to read two property files, The first is static and second is created during the build process. Please see below.
There is one static property file which I read in at the top: ./cfg/build.properties.
Then again reading another property file inside a target tag. The flow is described below.
There are two targets which will get executed in sequences.
First I am trying to create a property file using FOP in target GENERATE_PROPERTYFILE.
Then on the second target, READ_PROPERTY_FILE_GENERATE_XML, I am reading the property file created in the first step.
But the issue is, it is not picking a value for ${IssueObjects.ID} from the second property file.
Below is the snapshot of script.
<project name="fop4ant" default="run" basedir=".">
<property file="./cfg/build.properties" prefix="System"/>
<property environment="env"/>
<tstamp>
<format property="param_TouchTimeStamp" pattern="yyyyMMddHHmmssSS"/>
</tstamp>
<property name="param_TouchTimeStamp" value="" />
<property name="prop_File_XSL_FetchProbNSolObjects" value="${System.prop_Dir_stylesheet}/${System.prop_File_Stylesheet_FetchProbSol_CNReport}" />
<property name="prop_File_XML" value="${System.prop_Dir_temp}/Object-${param_TouchTimeStamp}.xml" />
<property name="prop_File_XML_Prob" value="${System.prop_Dir_temp}/Prob-${param_TouchTimeStamp}.xml" />
<property name="prop_File_COIDs" value="${System.prop_Dir_temp}/probCO-${param_TouchTimeStamp}.properties" />
<property name="prop_Dir_FOP" value="${env.FOP_HOME}"/>
<property name="prop_Dir_GS" value="${env.GS_HOME}"/>
<taskdef name="fop"
classname="org.apache.fop.tools.anttasks.Fop">
<classpath>
<fileset dir="${prop_Dir_FOP}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${prop_Dir_FOP}/build">
<include name="fop.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- #SECTION_BEGIN :: READ_PROPERTY_FILE_GENERATE_XML -->
<target name="generate-problem-item-productview">
<echo message="prop_XML_FILE_PROB :: ${prop_File_XML_Prob}" level="info" />
<!--Reading dynamically created property file-->
<property file="$prop_File_COIDs" prefix="IssueObjects"/>
<exec executable="export.exe">
<arg line="-xml_file=${prop_File_XML_Prob} -transfermode=${IssueObjects.ID}">
</exec>
</target>
<!-- #SECTION_END :: READ_PROPERTY_FILE_GENERATE_XML -->
<!-- #SECTION_BEGIN :: GENERATE_PROPERTYFILE-->
<target name="fetch-prob-sol-items">
<echo message="prop_File_XML :: ${prop_File_XML}" level="info" />
<echo message="prop_File_XSL_FetchProbNSolObjects :: ${prop_File_XSL_FetchProbNSolObjects}" level="info" />
<echo message="prop_File_COIDs :: ${prop_File_COIDs}" level="info" />
<echo message="prop_Dir_FOP :: ${prop_Dir_FOP}/fop.bat" level="info" />
<exec executable="${prop_Dir_FOP}/fop.bat">
<arg value="-xml"/>
<arg value="${prop_File_XML}"/>
<arg value="-xsl"/>
<arg value="${prop_File_XSL_FetchProbNSolObjects}"/>
<arg value="-foout"/>
<arg value="${prop_File_COIDs}"/>
</exec>
</target>
<!-- #SECTION_END :: GENERATE_PROPERTYFILE -->
<target name="run" depends="">
<echo message="start :: run" level="info" />
<antcall target="fetch-prob-sol-items" />
<antcall target="generate-problem-item-productview" />
<echo message="end :: run" level="info" />
</target>
</project>
In the READ_PROPERTY_FILE_GENERATE_XML section, replace the following...
<property file="$prop_File_COIDs" prefix="IssueObjects"/>
...with...
<property file="${prop_File_COIDs}" prefix="IssueObjects"/>
In the above example, curly braces have been added around the prop_File_COIDs reference.

Zend Server: Application name already exists

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>

failed to create task or type testng

This is my build.xml file. I am trying to call testNG.xml file to execute it from build.xml but i am getting below error.
<property name="bin.dir" value="${basedir}/bin" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="src.dir" value="${basedir}/src" />
<property name="res.dir" value="${basedir}/resources" />
<property name="server.dir" value="${basedir}/server" />
<path id="seleniumautomation.classpath">
<!-- <pathelement path="${lib.dir}" /> -->
<fileset dir="${lib.dir}">
<include name="*.jar" />
<include name="**/*.jar" />
</fileset>
<!--<fileset dir="${basedir}/server"> <include name="*.jar" /> <include
name="**/*.jar" /> </fileset> -->
</path>
<target name="clean">
<echo>Clean data</echo>
<delete failonerror="false" dir="lib"/>
</target>
<target name="create" depends="clean">
<echo>Creating directory.</echo>
<mkdir dir="lib"/>
</target>
<target name="copy" depends="create">
<echo>Coping jars</echo>
<copy todir="lib" overwrite="true">
<fileset dir="C:\backup\ToolsQA\ProjectThree\JarFiles" includes="**/*.jar" id="id" >
</fileset>
</copy>
</target>
<target name="compile" depends="copy">
<javac classpathref="seleniumautomation.classpath" includeantruntime="true" srcdir="src" destdir="bin" includes="**/*.java" verbose="true" >
</javac>
<echo>Java file compiled Successfully.</echo>
</target>
<target name="runtests" depends="compile">
<echo>ABCFD</echo>
<testng classpathref="seleniumautomation.classpath" useDefaultListeners="true">
<echo>2431234ABCFD</echo>
<xmlfileset dir="${basedir}" includes="TestNG.xml" />
</testng>
</target>
BUILD FAILED C:\backup\ToolsQA\ProjectThree\Build.xml:65: Problem:
failed to create task or type testng Cause: The name is undefined.
Action: Check the spelling. Action: Check that any custom tasks/types
have been declared. Action: Check that any /
declarations have taken place.
Please suggest....
You are missing taskdef tag like:
<taskdef resource="testngtasks" classpath="<Path where testng jar is in >/testng.jar"/>

Execute selenium test suit jar using ant

I have a Selenium RC testing project that uses JUNIT test cases. I have made a JAR file of it and I am executing that JAR through ANT build file:
My ant file looks like this:
*
<project name="test" default="run-all" basedir=".">
<property name="src" value="./src" />
<property name="lib" value="./lib" />
<property name="bin" value="./bin" />
<property name="report" value="./report" />
<path id="test.classpath">
<pathelement location="${bin}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="init">
<delete dir="${bin}" />
<mkdir dir="${bin}" />
</target>
<target name="exec" depends="init">
<delete dir="${report}" />
<mkdir dir="${report}" />
<mkdir dir="${report}/xml" />
<junit printsummary="yes" haltonfailure="no">
<batchtest fork="yes" todir="${report}/xml">
<resources>
<zipfileset src="BVTTest.jar" includes="**/*TestSuite.class"/>
</resources>
</batchtest>
<classpath>
<fileset dir="">
<include name="**/*.jar" />
</fileset>
</classpath>
</junit>
<junitreport todir="${report}">
<fileset dir="${report}/xml">
<include name="TEST*.xml" />
</fileset>
<report format="frames" todir="C:/eclipse/html" />
</junitreport>
</target>
<target name="start-selenium-server">
<java jar="selenium-server-standalone-2.25.0.jar" fork="true" spawn="true">
<arg line="-timeout 30" />
</java>
</target>
<target name="browse">
<exec executable="C:\Program Files\Internet Explorer\iexplore.exe">
<arg value="C:/eclipse/html/index.html"/>
</exec>
</target>
<target name="stop-selenium-server">
<get taskname="selenium-shutdown"
src="http://localhost:4444/selenium-server/driver/?cmd=shutDown"
dest="result.txt"
ignoreerrors="true" />
<echo message="selenium server stopped succesfully"/>
</target>
<target name="run-all">
<parallel>
<antcall target="start-selenium-server">
</antcall>
<sequential>
<echo taskname="waitfor" message="Wait for proxy server launch" />
<waitfor maxwait="1" maxwaitunit="minute" checkevery="100">
<http url="http://localhost:4444/selenium-server/
driver/?cmd=testComplete" />
</waitfor>
<antcall target="exec">
</antcall>
<antcall target="stop-selenium-server">
</antcall>
<antcall target="browse">
</antcall>
</sequential>
</parallel>
</target>
</project>
*
What it does is, it skips the <junit>; and after <mkdir> jumps directly to <junitreport>.
Please help.

Invoking FindBugs from Ant: passing a space-separated list of files to java

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>

Resources