I'm having a problem where the CSS isn't compiled at all. Ant seems to work as expected, nothing happens with my CSS files though.
Can anyone help figure out why my CSS isn't compiling?
Here's the output from running ant -v
$ ant -v
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
Trying the default build file: build.xml
Buildfile: /var/www/testsite/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-6-openjdk-amd64/jre
Detected OS: Linux
parsing buildfile /var/www/testsite/build.xml with URI = file:/var/www/testsite/build.xml
Project base dir set to: /var/www/testsite/www
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Override ignored for property "TODAY"
[property] Loading /var/www/testsite/www/build.properties
BUILD SUCCESSFUL
Total time: 0 seconds
graeme#ubuntu:/var/www/testsite$ ant -v
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
Trying the default build file: build.xml
Buildfile: /var/www/testsite/build.xml
Detected Java version: 1.6 in: /usr/lib/jvm/java-6-openjdk-amd64/jre
Detected OS: Linux
parsing buildfile /var/www/testsite/build.xml with URI = file:/var/www/testsite/build.xml
Project base dir set to: /var/www/testsite/www
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Override ignored for property "TODAY"
[property] Loading /var/www/testsite/www/build.properties
BUILD SUCCESSFUL
Total time: 0 seconds
Here's my build.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project name="testsite.co.uk" basedir="./www">
<tstamp>
<format property="TODAY" pattern="yyyy-M-dd-hh-mm" locale="en,UK"/>
</tstamp>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<property
name="yui-compressor.jar"
location="/home/testsite/Downloads/yui-ant/lib/yuicompressor-2.4.2.jar" />
<property
name="yui-compressor-ant-task.jar"
location="/home/testsite/Downloads/yui-ant/bin/yui-compressor-ant-task-0.5.1.jar" />
<path id="task.classpath">
<pathelement location="${yui-compressor.jar}" />
<pathelement location="${yui-compressor-ant-task.jar}" />
<pathelement location="/home/testsite/Downloads/yui-ant/lib/rhino-js-1.6r7.jar" />
<pathelement location="/home/testsite/Downloads/znerd-optipng-ant-task-ff33669/build/optipng-ant-task.jar" />
</path>
<taskdef
name="yui-compressor"
classname="net.noha.tools.ant.yuicompressor.tasks.YuiCompressorTask">
<classpath refid="task.classpath" />
</taskdef>
<taskdef name="optipng" classname="com.pensioenpage.jynx.optipng.OptiPNGTask" classpath="/home/testsite/Downloads/znerd-optipng-ant-task-ff33669/build/optipng-ant-task.jar" />
<property file="build.properties" />
<target name="export">
<tar destfile="./exported_latest_update_${TODAY} ${TSTAMP}.tar"
basedir="./"
includes = "www/**"
excludes=".git/**, .gitignore/**, www/secure/images/categories/**, www/secure/images/content/**, www/secure/images/products/**, www/secure/images/widgets/**">
<date datetime="08/14/2009 10:00 AM" when="after"/>
</tar>
</target>
<target name="css-frontend">
<property name="cssFilePath" value="./www/css"/>
<property name="cssUrlPath" value="/css"/>
<property name="frontendCss" value="build.frontend"/>
<delete>
<fileset dir="./www/css" includes="build.frontend.*.css" />
</delete>
<concat destfile="${cssFilePath}/${frontendCss}.css">
<fileset dir="./www/css" includes="reset.css" />
<fileset dir="./www/css" includes="text.css" />
<!--<fileset dir="./www/css" includes="forms.css" />-->
<fileset dir="./www/css" includes="tables.css" />
<fileset dir="./www/css" includes="vendor-logos.css" />
<fileset dir="./www/lib/javascript/fancybox2/" includes="jquery.fancybox.css" />
<!--<fileset dir="./www/css" includes="wp-panel.css" />-->
<fileset dir="./www/lib/javascript/jQuery.mmenu-master/dist/css" includes="jquery.mmenu.custom.css" />
<fileset dir="./www/css" includes="styles-2015.css" />
<fileset dir="./www/css" includes="loop54-styles.css" />
<fileset dir="./www/css" includes="feature_icons.css" />
<fileset dir="./www/css" includes="shopzilla.override.css" />
<fileset dir="./www/css/responsive-2015" includes="below-1100.css" />
<fileset dir="./www/css/responsive-2015" includes="below-1024.css" />
<fileset dir="./www/css/responsive-2015" includes="below-980.css" />
<fileset dir="./www/css/responsive-2015" includes="above-980.css" />
<fileset dir="./www/css/responsive-2015" includes="below-690.css" />
<fileset dir="./www/css/responsive-2015" includes="below-500.css" />
<fileset dir="./www/css/responsive-2015" includes="below-320.css" />
<fileset dir="./www/css/responsive-2015" includes="retina-screens.css" />
</concat>
<concat destfile="${cssFilePath}/build.wp-style.css">
<fileset dir="./www/css" includes="reset.css" />
<fileset dir="./www/css" includes="text.css" />
<fileset dir="./www/css" includes="vendor-logos.css" />
<fileset dir="./www/css" includes="wp-style.css" />
</concat>
<concat destfile="${cssFilePath}/build.checkout.css">
<fileset dir="./www/lib/javascript/fancybox2/" includes="jquery.fancybox.css" />
<fileset dir="./www/css" includes="reset.css" />
<fileset dir="./www/css" includes="text.css" />
<fileset dir="./www/css" includes="forms.css" />
<fileset dir="./www/css" includes="tables.css" />
<!--<fileset dir="./www/css" includes="wp-panel.css" />-->
<fileset dir="./www/css" includes="one-page-checkout.css" />
</concat>
<checksum file="${cssFilePath}/${frontendCss}.css" property="css_md5"/>
<property name="frontendCssMd5" value="build.frontend"/>
<move file="${cssFilePath}/${frontendCss}.css" tofile="${cssFilePath}/${frontendCssMd5}.css"/>
<yui-compressor
warn="false"
munge="true"
preserveallsemicolons="false"
fromdir="${cssFilePath}"
todir="${cssFilePath}/">
<include name="${frontendCssMd5}.css" />
<include name="build.wp-style.css" />
<include name="build.checkout.css" />
<include name="720plus.css" />
<include name="719minus.css" />
</yui-compressor>
</target>
</project>
Related
I got a Spring project built using Ant that fails when executed on Jenkins, but not when I run the exact same Ant target from Eclipse (Ant view).
Jenkins version is 2.19.4
Jenkins Console Output excerpt
Started by user Morin, Charles
Building in workspace D:\APPS\jenkins-2.19.4\workspace\MY-PROJECT
Using locally configured password for connection to :pserver:MY-SERVICE-ACCOUNT#MY-CVS-SERVER:D:/DATA/REPOSITORIES/MY-CVS-REPO
cvs update -d -P -r HEAD -D 26 Jan 2017 10:09:39 -0500 MY-PROJECT
Using locally configured password for connection to :pserver:MY-SERVICE-ACCOUNT#MY-CVS-SERVER:D:/DATA/REPOSITORIES/MY-CVS-REPO
cvs rlog -S -d25 Jan 2017 00:08:54 -0500<26 Jan 2017 10:09:39 -0500 MY-PROJECT
[MY-PROJECT] $ cmd.exe /C "D:\APPS\jenkins-2.19.4\ant\bin\ant.bat -file build.xml compile && exit %%ERRORLEVEL%%"
Buildfile: build.xml
[echo] ========================================================================
[echo] *** Starting MY-PROJECT build
[echo] ========================================================================
print-version:
[echo] Java/JVM version: 1.6
[echo] Java/JVM detailed version: 1.7.0_25
create-directories:
compile:
[javac] Compiling 41 source files to D:\APPS\jenkins-2.19.4\workspace\MY-PROJECT\target\classes
[javac] Note: Hibernate JPA 2 Static-Metamodel Generator 5.1.0.Final
[javac] D:\APPS\jenkins-2.19.4\workspace\MY-PROJECT\src\path\to\my\class\MyClass.java:28: error: cannot find symbol
[javac] import path.to.my.class.MyClass_;
[javac] ^
[javac] symbol: class MyClass_
[javac] location: package path.to.my.class
The problem is that my JPA metamodels are not being found during the compilation. However, we can see the following line that confirms the generation of JPA Metamodels:
Note: Hibernate JPA 2 Static-Metamodel Generator 5.1.0.Final
The only difference I can see is in the print-version Ant target. When executed locally, I got this:
print-version:
[echo] Java/JVM version: 1.7
[echo] Java/JVM detailed version: 1.7.0_25
I also have several other projects with the exact same setup, and I don't have that issue.
build.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="MY-PROJECT" default="create-war-and-deploy-to-jboss" basedir="." xmlns:sonar="antlib:org.sonar.ant" xmlns:jacoco="antlib:org.jacoco.ant">
<property name="verbose" value="false" />
<property name="javaVersion" value="1.7" />
<!-- Provides access to OS environment variables (eg: env.USERNAME) -->
<property environment="env" />
<!-- Application's directories -->
<property name="dir.build" value="${basedir}/build" />
<property name="dir.src" value="${basedir}/src" />
<property name="dir.dist" value="${basedir}/dist" />
<property name="dir.lib" location="${basedir}/lib" />
<property name="dir.target" value="${basedir}/target" />
<property name="dir.build.classes" value="${dir.target}/classes" />
<property name="dir.test" value="${basedir}/test" />
<property name="dir.web" value="${basedir}/WebContent" />
<property name="dir.webinf.lib" value="${dir.web}/WEB-INF/lib" />
<!-- Loading the application.properties file -->
<property file="${dir.src}/resources/application.properties" prefix="app." />
<!-- Loading the build.properties file -->
<property file="build.properties" prefix="buildProp." />
<tstamp>
<format property="build.time" pattern="yyyy-MM-dd HH:mm" />
</tstamp>
<echo message="========================================================================" />
<echo message="*** Starting ${app.name} build " />
<echo message="========================================================================" />
<!-- JBoss directories -->
<property name="dir.jboss" value="${buildProp.jboss.home}" />
<property name="dir.jboss.domain" value="${dir.jboss}/${buildProp.jboss.domain}" />
<property name="dir.jboss.libs" value="${dir.jboss}/${buildProp.jboss.libs}" />
<property name="dir.jboss.deploy" value="${dir.jboss.domain}/${buildProp.jboss.deploy}" />
<!-- Path for unit tests -->
<path id="run.classpath.tests">
<pathelement path="${dir.build.classes}" />
<pathelement path="${dir.test}/build/classes" />
<path refid="compile.classpath.tests" />
</path>
<!-- Provided dependencies from the container -->
<path id="compile.classpath.server">
<fileset dir="${dir.lib}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- Dependencies specific to this application -->
<path id="compile.classpath.web">
<fileset dir="${dir.web}/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>
</path>
<path id="compile.classpath.target">
<fileset dir="${dir.lib}">
<include name="hibernate-jpamodelgen-5.1.0.Final.jar" />
</fileset>
<fileset dir="${dir.target}">
<include name="**/*.java" />
</fileset>
</path>
<!-- Dependencies specifically for unit testing purposes -->
<path id="compile.classpath.tests">
<fileset dir="${dir.test}/lib/">
<include name="junit-4.6.jar" />
<include name="mockito-all-1.9.5.jar" />
</fileset>
<fileset dir="${dir.webinf.lib}" />
<pathelement location="${dir.build.classes}" />
<path refid="compile.classpath.server" />
</path>
<!-- PRINT-VERSION -->
<target name="print-version">
<echo>Java/JVM version: ${ant.java.version}</echo>
<echo>Java/JVM detailed version: ${java.version}</echo>
</target>
<!-- BUILD-DISTRIBUTION -->
<target
name="build-distribution"
description="Generate Deployment unit and stage to appserver directory."
depends="
clean,
run-unit-tests,
create-war,
run-sonarqube-analysis">
<manifest file="${dir.web}/META-INF/MANIFEST.MF">
<attribute name="Manifest-Version" value="1.0" />
<attribute name="Ant-Version" value="1.7.0" />
<attribute name="Created-By" value="${env.USERNAME}" />
<attribute name="Implementation-Title" value="${app.name}" />
<attribute name="Implementation-Version" value="${app.version}" />
<attribute name="Implementation-Vendor" value="Canada Revenue Agency" />
<attribute name="Implementation-Date" value="${build.time}" />
<attribute name="Built-By" value="${env.USERNAME}" />
<attribute name="Dependencies" value="org.hibernate" />
</manifest>
<propertyfile file="${dir.src}/resources/application.properties">
<entry key="lastUpdate" value="${build.time}" />
</propertyfile>
</target>
<!-- CLEAN -->
<target name="clean"
description="Cleans up build-related temporary directories."
depends="delete-directories" />
<!-- CREATE-DIRECTORIES -->
<target name="create-directories" >
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.dist}" />
<mkdir dir="${dir.build.classes}" />
<mkdir dir="${dir.web}/WEB-INF/classes" />
<mkdir dir="${dir.test}/build" />
<mkdir dir="${dir.test}/build/classes" />
<mkdir dir="${dir.test}/reports" />
</target>
<!-- DELETES-DIRECTORIES -->
<target name="delete-directories">
<delete dir=".sonar" />
<!-- /build -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${dir.build}" includes="**/*" />
<exclude name=".cvsignore" />
</delete>
<!-- /dist -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${dir.dist}" includes="**/*" />
<exclude name=".cvsignore" />
</delete>
<!-- /WEB-INF/classes -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${dir.web}/WEB-INF/classes">
<include name="**/*" />
</fileset>
<fileset dir="${dir.web}/WEB-INF/src">
<include name="**/*" />
</fileset>
</delete>
<!-- /target -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${dir.target}" includes="**/*" />
<exclude name=".cvsignore" />
</delete>
<!-- /test/build -->
<delete dir="${dir.test}/build" />
<!-- /test/reports -->
<delete includeEmptyDirs="true" failonerror="false">
<fileset dir="${dir.test}/reports" />
</delete>
<!-- Existing WAR file and JBoss marker files -->
<delete dir="${dir.jboss.deploy}/${app.name}.war" />
<delete file="${dir.jboss.deploy}/${app.name}.war" />
<delete file="${dir.jboss.deploy}/${app.name}.war.deployed" />
</target>
<!-- COMPILE -->
<target name="compile" depends="print-version,create-directories">
<javac destdir="${dir.build.classes}" verbose="${verbose}" debug="on" fork="true" failonerror="true" source="${javaVersion}" target="${javaVersion}" includeantruntime="false">
<classpath>
<path refid="compile.classpath.server" />
<path refid="compile.classpath.target" />
<path refid="compile.classpath.web" />
</classpath>
<src path="${dir.src}" />
<compilerarg value="-Xlint:deprecation" />
<compilerarg value="-Xlint:unchecked" />
</javac>
<!--copy property files to classes directory -->
<copy todir="${dir.build.classes}">
<fileset dir="${dir.src}">
<include name="**/*.properties" />
<include name="META-INF/**/*" />
</fileset>
</copy>
</target>
<!-- COMPILE-TESTS -->
<target name="compile-tests" depends="create-directories,compile">
<javac srcdir="${dir.test}/src" destdir="${dir.test}/build/classes" verbose="${verbose}" debug="on" fork="true" source="${javaVersion}" target="${javaVersion}" includeantruntime="false">
<classpath refid="compile.classpath.tests" />
<compilerarg value="-Xlint:deprecation" />
<compilerarg value="-Xlint:unchecked" />
</javac>
</target>
<!-- RUN-UNIT-TESTS -->
<target name="run-unit-tests" depends="compile-tests" description="Runs all unit test classes under the test package.">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="test/lib/org.jacoco.ant-0.7.2.201409121644.jar"/>
<classpath path="test/lib/org.jacoco.agent_0.7.2.201409121644.jar"/>
<classpath path="test/lib/org.jacoco.core_0.7.2.201409121644.jar"/>
<classpath path="test/lib/org.jacoco.report_0.7.2.201409121644.jar"/>
</taskdef>
<jacoco:coverage destfile="${dir.target}/jacoco.exec">
<junit fork="true" printsummary="yes" haltonfailure="yes" showoutput="no">
<classpath refid="run.classpath.tests" />
<formatter type="xml" />
<batchtest fork="yes" todir="${dir.test}/reports">
<fileset dir="${dir.test}/src">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
</target>
<!-- CREATE-WAR -->
<target name="create-war" description="Creates a WAR file including all compiled classes and resources." depends="compile">
<war destfile="dist/${app.name}.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent" />
<classes dir="${dir.build.classes}" />
</war>
</target>
<!-- CREATE-WAR-AND-DEPLOY -->
<target name="create-war-and-deploy-to-jboss" description="Creates a WAR file including all compiled classes and resources, and deploys the app to jboss" depends="create-war,deploy-to-jboss" />
<!-- RUN-SONARQUBE -->
<target name="run-sonarqube-analysis" description="Runs the SonarQube analysis and updates statistics on the server." depends="create-war">
<property file="sonar.properties" prefix="sonar." />
<!-- SonarQube properties -->
<property name="sonar.exclusions" value="${sonar.exclusions}" />
<property name="sonar.host.url" value="${sonar.host.url}" />
<property name="sonar.jacoco.reportPath" value="${sonar.jacoco.reportPath}" />
<property name="sonar.java.binaries" value="${sonar.java.binaries}" />
<property name="sonar.java.coveragePlugin" value="${sonar.java.coveragePlugin}" />
<property name="sonar.java.libraries" value="${sonar.java.libraries}" />
<property name="sonar.java.source" value="${javaVersion}" />
<property name="sonar.junit.reportsPath" value="${sonar.junit.reportsPath}" />
<property name="sonar.projectKey" value="${sonar.projectKey}" />
<property name="sonar.projectVersion" value="${app.version}" />
<property name="sonar.projectName" value="${sonar.projectName}" />
<property name="sonar.sources" value="${sonar.sources}" />
<property name="sonar.sourceEncoding" value="${sonar.sources.sourceEncoding}" />
<property name="sonar.tests" value="${sonar.tests}" />
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="${dir.lib}/sonarqube-ant-task-2.4.1.jar" />
</taskdef>
<sonar:sonar/>
</target>
<!-- DEPLOY-TO-JBOSS -->
<target name="deploy-to-jboss" depends="create-war">
<!--delete war file if it already exists and was copied over, we need a directory now-->
<delete file="${dir.jboss.deploy}/${app.name}.war" />
<delete file="${dir.jboss.deploy}/${app.name}.war.deployed" />
<!-- copy all of the files except one that will trigger the deployment -->
<copy todir="${dir.jboss.deploy}">
<fileset file="${dir.dist}/${app.name}.war" />
</copy>
</target>
</project>
Thank you
From Manage Jenkins-->Configure System--JDK section, add both JDKs to JDK Installation. From your Job Configuration, in the JDK section, explicitly choose the 1.7 JDK.
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"/>
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.
How can I generate HTML reports from JUnit using Ant when there are test failures?
The reports are generated when there are no failures.
Also, how can we define our own XSLT for the report generation?
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="Ant Example" default="all" basedir=".">
<property name="project_name" value="junitSamples" />
<property name="src" location="src" />
<property name="build" location="build/classes" />
<property name="lib" location="lib" />
<property name="reports" location="reports" />
<target name="init" depends="clean">
<mkdir dir="${build}" />
<mkdir dir="${lib}" />
<mkdir dir="${reports}" />
<mkdir dir="${reports}/raw/" />
<mkdir dir="${reports}/html/" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${build}" description="compile the source code ">
<classpath>
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="clean">
<delete dir="build" />
<delete dir="${reports}" />
</target>
<target name="run-tests" depends="compile">
<junit printsummary="yes" haltonfailure="yes" showoutput="yes">
<classpath>
<pathelement path="${build}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
<batchtest fork="yes" todir="${reports}/raw/">
<formatter type="xml" />
<fileset dir="${src}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="test" depends="run-tests">
<junitreport todir="${reports}">
<fileset dir="${reports}/raw/">
<include name="TEST-*.xml" />
</fileset>
<report format="noframes" todir="${reports}\html\" />
</junitreport>
</target>
<target name="all" depends="clean, test" />
</project>
To specify your own stylesheets, use the "styledir" attribute:
<report styledir="${resources}/junit" format="..." todir="..." />
As noted, you must use the "junit-noframes.xsl" stylesheet name.
JUnit report docs.
You set haltonfailure="yes" it means that if one test fails build operation will stop.
This is from the ant documentation:
"Stop the build process if a test fails (errors are considered failures as well)."
Read more here- https://ant.apache.org/manual/Tasks/junit.html
I have an ant script that I am trying to run my junit test from. It runs all but the junit portion of the ant with no errors. Anyone know why it's not hitting this portion of my script?
<?xml version="1.0"?>
<property file="build.properties" />
<property name="test.class.name" value="edu.psu.ist.probability.TestProbability" />
<path id="test.classpath">
<pathelement location="${classes}" />
<pathelement location="/lib/junit.jar" />
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef resource="checkstyletask.properties" classpath="${checkstyle}" />
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath>
<pathelement path="${findbugs.jar}" />
</classpath>
</taskdef>
<!--
Encapsulates the process of starting up program.
-->
<target name="run" depends="build">
<echo>-----------RUN-----------</echo>
<java classname="${main}" fork="true">
<!-- fork needed for running on OS X -->
<classpath>
<pathelement location="${jar}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</java>
</target>
<!--
Encapsulates the process of packaging (jarring) program.
-->
<target name="build" depends="document">
<echo>---------BUILD--------</echo>
<jar destfile="${jar}" basedir="${classes}" />
</target>
<!--
Encapsulates the process of generating javadoc for program.
-->
<target name="document" depends="findbugs">
<echo>-------DOC--------</echo>
<javadoc sourcepath="${src}" defaultexcludes="yes" destdir="${docs}" executable="C:\Program Files (x86)\Java\jdk1.6.0_20\bin\javadoc.exe" author="true" version="true" use="true" windowtitle="Decisions API">
</javadoc>
</target>
<!--
Encapsulates the process of executing findbugs against program.
-->
<target name="findbugs" depends="style">
<echo>----------FINDBUGS----------</echo>
<findbugs home="${findbugs}" output="html" outputFile="${findbugs.output}" failOnError="true" stylesheet="fancy.xsl">
<auxClasspath>
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</auxClasspath>
<sourcePath path="${src}"/>
<class location="${classes}" />
</findbugs>
</target>
<!--
Encapsulates the process of style-checking program.
-->
<target name="style" depends="compile">
<echo>---STYLE---</echo>
<checkstyle config="${checkstyleconfig}" classpath="${classes}">
<fileset dir="${src}" includes="**/*.java"
excludes="**/DecisionsProgram.java, **/*Test.java" />
</checkstyle>
</target>
<!--
Encapsulates the process of compiling program.
-->
<target name="compile" depends="clean">
<echo>------------COMPILE--------</echo>
<javac destdir="${classes}">
<src path="${src}" />
<classpath>
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<!--
Encapsulates the process of cleaning up program directory structure.
-->
<target name="clean">
<!-- make sure dirs exist first, to prevent error -->
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${docs}" />
<mkdir dir="${reports}" />
<!-- now delete them -->
<delete dir="${classes}" />
<delete dir="${dist}" />
<delete dir="${docs}" />
<delete dir="${reports}" />
<!-- now recreate them so they can be used -->
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${docs}" />
<mkdir dir="${reports}" />
</target>
<target name="test" depends="compile">
<echo>-------JUNIT----------</echo>
<junit fork="yes" haltonfailure="yes">
<test name="${test.class.name}" />
<formatter type="plain" usefile="false" />
<classpath refid="test.classpath" />
</junit>
</target>
There is no target which is invoking "test".
One possibility is to replace
<target name="style" depends="compile">
with
<target name="style" depends="test">