TestNG test-output folder getting generated on Desktop when expected to be in project folder - ant

I have a setup of Selenium WebDriver + TestNG + Ant framework in my automation project. Running webdriver + TestNG tests from Ant using build.xml was working absolutely fine a few months ago. TestNG was generating the test-output folder in the project directory as expected. Now when I run my testng tests from ANT it's generating the default report folder test-output on my Desktop (home/user/Desktop). I don't know why it is happening.
This is my build.xml file:
<project name="InitialConfigProject" default="start" basedir=".">
<!-- ========== Initialize Properties =================================== -->
<property environment="env"/>
<property file="./app.properties"/>
<property name="ws.home" value="${basedir}"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="browser" value="/usr/bin/google-chrome"/>
<property name="mail_body_file" value="${basedir}/email_body.txt"/>
<property name="buildID" value="IND3.2.0"/>
<property name="sendmailscript_path" value="${basedir}/sendmail.sh"/>
<property name="mail_subject" value="Automated_test_execution_of_${buildID}"/>
<!-- ====== Set the classpath ==== -->
<target name="setClassPath" unless="test.classpath">
<path id="classpath_jars">
<fileset dir="${ws.home}/lib" includes="*.jar"/>
</path>
<pathconvert pathsep=":" property="test.classpath" refid="classpath_jars"/>
</target>
<!-- ============ Initializing other stuff =========== -->
<target name="init" depends="setClassPath">
<tstamp>
<format property="timestamp" pattern="dd/MM/yyyy hh:mm aa" />
</tstamp>
<!--
<condition property="ANT"
value="${env.ANT_HOME}/bin/ant.bat"
else="${env.ANT_HOME}/bin/ant">
<os family="windows" />
</condition> -->
<property name="build.log.dir" location="${basedir}/buildlogs" />
<mkdir dir="${build.log.dir}"/>
<property name="build.log.filename" value="build_${timestamp}.log"/>
<record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
<echo message="build logged to ${build.log.filename}"/>
<echo message="Loading TestNG.." />
<taskdef name="testng" classpath="${test.classpath}" classname="org.testng.TestNGAntTask" />
</target>
<!-- cleaning the destination folders -->
<target name="clean">
<delete dir="${test.dest}"/>
</target>
<!-- compiling files -->
<target name="compile" depends="init, clean" >
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.dest}" includes="**/*"/>
</delete>
<echo message="making directory..."/>
<mkdir dir="${test.dest}"/>
<copy file="${ws.home}/app.properties" todir="${ws.home}/build" />
<copy file="${ws.home}/resources/testdata/testDataSet1.properties" todir="${ws.home}/build" />
<echo message="compiling source files..."/>
<javac
debug="true"
destdir="${test.dest}"
srcdir="${test.src}"
target="1.6"
classpath="${test.classpath}"
includeantruntime="true"
>
</javac>
</target>
<!-- run -->
<target name="run" depends="compile">
<testng outputdir="${ws.home}/test-output" classpath="${test.classpath}:${test.dest}" suitename="Praxify Sanity Suite">
<xmlfileset dir="${ws.home}" includes="testng.xml"/>
</testng>
</target>
<!-- ========== Generating reports using XSLT utility ============== -->
<target name="testng-xslt-report">
<delete dir="${basedir}/testng-xslt">
</delete>
<mkdir dir="${basedir}/testng-xslt">
</mkdir>
<xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html"
processor="SaxonLiaison">
<param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />
<param expression="true" name="testNgXslt.sortTestCaseLinks" />
<param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
<param expression="true" name="testNgXslt.showRuntimeTotals" />
<classpath refid="classpath_jars"></classpath>
</xslt>
</target>
<!-- Starting point of the execution, should be dependent on target "run".
Target sequence will be:
start (not_execute) ==> run (not_execute) ==> compile (not_execute) ==> init (execute) ==> clean (execute)
start (execute) <== testng-xslt-report (execute) <== run (execute) <== compile (execute) <==
Suitable for ANT 1.7. Currently using this ====================== -->
<target name="start" depends="run, testng-xslt-report">
<tstamp prefix="getTime">
<format property="TODAY" pattern="MM-dd-yyyyhhmmaa"/>
</tstamp>
<echo message="sending report as mail...."/>
<property name="execution_time" value="${buildID}_${getTime.TODAY}"/>
<property name="dest_file" value="/home/xtremum/Reports/${execution_time}.zip"/>
<zip destfile="/home/xtremum/Reports/${execution_time}.zip" basedir="${basedir}/testng-xslt"/>
<property name="report_attachment_file" value="${dest_file}"/>
<exec executable="${sendmailscript_path}" newenvironment="false">
<arg value="${mail_subject}"/>
<arg value="${mail_recipient}"/>
<arg value="${report_attachment_file}"/>
<arg value="${mail_body_file}"/>
</exec>
</target>
Just for the record:
1. I am using Eclipse Juno.
2. I have installed TestNG plugin on Eclipse so that I can run tests directly from eclipse by right clicking on testng.xml and going for Run.
3. I have installed ANT 1.7 on my Ubuntu machine and have set my ANT_HOME pointing to /usr/share/ant. And I looked up in Windows -> Preferences -> Ant -> Runtime -> Ant Home Entries (Default) and they seem to have references to ant 1.8.3 libraries (JARS) which are inside the Eclipse package (eclipse/plugins/). Is there anything wrong here?
4. I am running the tests via ant from eclipse and not from command line.
I am not getting any build errors. Tests are getting executed but the test-output folder is getting created on Desktop. Any help?

If you are running through the testng plugin option, the output folder would be the one you specify in Project->Properties->TestNG->OutputDirectory

Related

ANT compile is working fine but ANT run not working build failed "failed to create task or type testng"

Below is my Build.xml file. when i compile my project it shows Build Success but when i run it then Build Failed "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.
<?xml version="1.0" encoding="UTF-8"?>
<project name="projectName" default="clean" basedir="C:\Users\saad bin usman\workspace\testNG"> <!-- dot indicates that basedir is pointing towards project root directory -->
<!-- ========== Initialize Properties =================================== -->
<property name="ws.home" value="${basedir}" />
<property name="ws.jars" value="D:\jars" />
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.result" value="test-output"/>
<echo> value of base dir = ${basedir} </echo>
<!-- properties for copying the results -->
<tstamp>
<format property="year" pattern="yyyy" />
<format property="DSTAMP" pattern="yyyy-MM-dd" />
<format property="TSTAMP" pattern="HH:mm:ss" />
<format property="dateversion" pattern="yyyy.MM.dd.HH:mm:ss" />
<format property="time.stamp" pattern="yyyy-MM-dd_HH-mm-ss aa_"/>
</tstamp>
<property name="testng.report.dir" value="${ws.home}/testngReports/${time.stamp}"/>
<property name="testngXslt.report.dir" value="${ws.home}/testngXsltReports/${time.stamp}"/>
<!-- ====== For setting the classpath ==== -->
<target name="setClassPath" unless="test.classpath">
<path id="classpath_jars">
<fileset dir="${ws.jars}" includes = "*.jar"/>
</path>
<pathconvert pathsep=":"
property="test.classpath"
refid="classpath_jars" />
</target>
<!-- ============ Initializing other stuff =========== -->
<target name="init" depends="setClassPath">
<tstamp>
<format property="start.time" pattern="MM-dd-yyyy (HH-mm-ss)"/>
</tstamp>
<condition property="ANT"
value="$(env.ANT_HOME)/bin/ant.bat"
else="$(env.ANT_HOME)/bin/ant">
<!-- os family="windows" /-->
<os family="mac" />
</condition>
<!--
<!- use direct path for classpath if you don't prefer to use 'lib' directory: classpath="/Users/yash/Documents/Jar Files/testng-6.8.jar" ->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="./lib/testng.jar"/>
</classpath>
</taskdef>
-->
</target>
<target name="all">
</target>
<!-- cleaning the destination folders -->
<target name="clean">
<echo message="deleting existing build directory"/>
<delete dir="${test.dest}"/>
</target>
<!-- target for compiling the java files -->
<target name="compile" depends="init, clean">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.dest}" includes="**/*"/>
</delete>
<echo message="making directory....."/>
<mkdir dir="${test.dest}"/>
<echo message="classpath-------: ${test.classpath}"/>
<echo message="compiling....."/>
<javac
debug="true"
destdir="${test.dest}"
srcdir="${test.src}"
classpath="${test.classpath}"
includeantruntime="true"/>
</target>
<!-- build -->
<target name="build" depends="init">
</target>
<!-- ========== Test executions & Generating reports using Testng utility for multiple suites ============== -->
<!-- run -->
<target name="run" depends="compile">
<taskdef resource="testngtasks" classpath="D:\saad bin usman\saad's doc\softwares\eclipse\plugins\org.testng.eclipse_6.9.8.201510130443\lib\*.jar" />
<testng classpath="classpath.test" suitename="smsweb" outputDir="test-output" >
<xmlfileset dir="${ws.home}" includes="testng.xml" />
</testng>
</target>
<target name="testngReportCopyAndReportParser">
<!-- Copy to TestNG report directory-->
<mkdir dir="${testngDir}">
</mkdir>
<!-- to copy previous suite result to TestNG report directory -->
<copy todir="${testngDir}">
<fileset dir="test-output"/>
</copy> <!-- end of Testng Report -->
</target>
<!-- ========== Test executions & Generating reports using Testng XSLT utility for multiple suites ============== -->
<!-- run -->
<target name="runAsTestngXslt" depends="compile">
<!--suite 1 begin -->
<property name="suite.web.CopyRegressionCustomer" value="CopyRegressionCustomer" />
<testng classpath="${test.classpath}:${test.dest}" suitename="CopyRegressionCustomer" outputDir="test-output" >
<xmlfileset dir="." includes="webSuites/CopyRegressionCustomer.xml" />
</testng>
<antcall target="testngXsltReportCopy">
<param name="testngXsltDir" value="${testngXslt.report.dir}${suite.web.CopyRegressionCustomer}"/>
</antcall>
<!--suite 2 begin -->
<property name="suite.web.Copy2RegressionCustomer" value="Copy2RegressionCustomer" />
<testng classpath="${test.classpath}:${test.dest}" suitename="Copy2RegressionCustomer" outputDir="test-output" >
<xmlfileset dir="." includes="webSuites/Copy2RegressionCustomer.xml" />
</testng>
<antcall target="testngXsltReportCopy">
<param name="testngXsltDir" value="${testngXslt.report.dir}${suite.web.Copy2RegressionCustomer}"/>
</antcall>
</target>
<target name="testngXsltReportCopyAndReportParser">
<!-- Copy to TestNG report directory-->
<mkdir dir="${testngXsltDir}">
</mkdir>
<!-- to copy previous suite result to TestngXslt report folder -->
<xslt in="${ws.home}/test-output/testng-results.xml" style="src/xslt/testng-results.xsl"
out="${testngXsltDir}/index.html" classpathref="test.c" processor="SaxonLiaison">
<param name="testNgXslt.outputDir" expression="${testngXsltDir}" />
<param name="testNgXslt.showRuntimeTotals" expression="true" />
<param name="testNgXslt.sortTestCaseLinks" expression="true" />
<param name="testNgXslt.testDetailsFilter" expression="FAIL,SKIP,PASS,CONF,BY_CLASS" />
</xslt> <!-- end of TestngXslt Report -->
</target>
<path id="test.c">
<fileset dir="${ws.jars}" includes="*.jar">
<include name="mail.jar"/>
<include name="activation-1.0.2.jar"/>
</fileset>
</path>
<!-- ========== Generating reports using Testng XSLT utility for single suite only ============== -->
<target name="report" depends="run">
<!-- TestngXslt report -->
<mkdir dir="${testngXslt.report.dir}">
</mkdir>
<!-- to copy previous suite result to TestngXslt report folder -->
<xslt in="${ws.home}/test-output/testng-results.xml" style="src/xslt/testng-results.xsl"
out="${testngXslt.report.dir}/index.html" classpathref="test.c" processor="SaxonLiaison">
<param name="testNgXslt.outputDir" expression="${testngXslt.report.dir}" />
<param name="testNgXslt.showRuntimeTotals" expression="true" />
<param name="testNgXslt.sortTestCaseLinks" expression="true" />
<param name="testNgXslt.testDetailsFilter" expression="FAIL,SKIP,PASS,CONF,BY_CLASS" />
</xslt> <!-- end of TestngXslt Report -->
</target>
<target name="RunAndViewReport" depends="report">
<exec executable="${browser}" spawn="yes">
<arg line="'file:///${testngXslt.report.dir}/index.html'" />
</exec>
</target>
<target name="sendMail" depends="RunAndViewReport">
<zip destfile="${testngXslt.report.dir}/Report.zip" basedir="${testngXslt.report.dir}"/>
<mail mailhost="smtp.gmail.com" mailport="465" subject="Notification of TESTNG build result" ssl="false" user="automationmoolya#gmail.com" password="moolya#universe">
<from address="automationmoolya#gmail.com"/>
<to address="yagnesh#moolya.com"/>
<message>The build has finished. A details report of this build is attached</message>
<attachments>
<fileset dir="testngXslt.report.dir">
<include name="**/*.zip"/>
</fileset>
</attachments>
</mail>
</target>
<target name="install-jars" description="Install ANT optional jars">
<get dest="${ws.home}/lib/mail.jar" src="file:///${ws.home}/lib/mail.jar"/>
<fileset dir="${ws.jars}" includes="*.jar">
<include name="mail.jar"/>
<include name="activation-1.0.2.jar"/>
</fileset>
</target>
</project>
use run like below
<!-- run -->
<target name="run" depends="compile">
<testng classpath="${test.classpath}:${test.dest}">
<xmlfileset dir="${ws.home}" includes="testng.xml"/>
</testng>
</target>
Your taskdef is nested inside the task you're trying to use. That's now how it works. Define the task first, then run it.
<taskdef resource="testngtasks" classpath="/full/path/to/testng.jar" />
<testng classpathref="classpath.test" suitename="smsweb" outputDir="test-output" >
<xmlfileset dir="${ws.home}" includes="testng.xml" />
</testng>

TestNg/Selenium call by ant always return Cannot find class in the classpath

I'm pretty new with this setup. And having issue to call my project with TestNG by ant.
I can run the testng.xml without any problem in Eclipse but I alway receive Cannot find class in classpath by ant.
Build.xml
<project basedir="." default="runTest" name="Ant file for TestNG">
<property name="src" location="src" />
<property name="bin" location="bin" />
<property name="telus" location="C:\ESP_Testware\ESP_Projects\Selenium\telus-pharma-integration-tests\src\test\resources\suite\local" />
<property name="libs" location="lib" />
<path id="class.path">
<pathelement location="${libs}/testng-6.4.jar" />
<pathelement location="${libs}/selenium-java-client-driver.jar" />
<pathelement location="${libs}/selenium-server-standalone-2.39.0.jar" />
<pathelement location="${bin}"/>
<pathelement location="${telus}"/>
</path>
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="${libs}/testng-6.4.jar"/>
</classpath>
</taskdef>
<target name="runTest">
<echo message="mkdir"/>
<mkdir dir="testng_output"/><!-- Create the output directory. -->
<echo message= "TestNg Start"/>
<testng outputdir="testng_output" classpathref="class.path">
<xmlfileset dir="${telus}" includes="testng.xml"/>
<!-- <xmlfileset dir="." includes="TestNG2.xml"/> -->
</testng>
</target>
</project>
Testng.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Bolt harness QA" verbose="1">
<parameter name="test.env" value="qa" />
<parameter name="selenium.url" value="https://www.google.com" />
<!-- Valid values for browser: FF, IE, Chrome -->
<parameter name="selenium.browser" value="Chrome" />
<listeners>
<listener class-name="com.gdo.test.integration.listener.SoftAssertTestListener" />
</listeners>
<test name="Test_MS_Website" preserve-order="true">
<classes>
<class name="com.gdo.telus.SC006">
<methods>
<include name="Web_InvalidPassword" />
<exclude name="Web_LockedAccount" />
</methods>
</class>
</classes>
</test>
</suite>
My Class are at this path :
C:\ESP_Testware\ESP_Projects\Selenium\telus-pharma-integration-tests\src\test\java\com\gdo\telus
Thanks for your help.
Try my build.xml file, I did add the ReportNG plugin into this build.xml file to generate better looking reports instead of the default TestNG reports. You can just download the jar file for ReportNG and place it into your lib folder and it should still work fine:
<project name="Some Bullshit Goes Here" default="clean" basedir=".">
<!-- Initilization properties -->
<!-- <property name="lib.dir" value="${basedir}/lib"/> -->
<!-- using the ${basedir} allows you to use relative paths. It will use the working directory and add folders that you specify -->
<property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="hardcoded value can go here"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="bin.dir" value="${basedir}/bin"/>
<property name="output.dir" value="${basedir}/output"/>
<!-- I chose to hardcode the location where my jar library files will be, it will be used for compilation. Again you can set relative path if you wish.-->
<path id="assloadoflibs">
<fileset dir="/automated/tests/library">
<include name="*.jar"/>
</fileset>
<pathelement path="${basedir}/bin"/>
</path>
<!-- setting libraries -->
<target name="setClassPath">
<path id="classpath_jars">
<pathelement path="${basedir}/"/>
<fileset dir="/automated/tests/library" includes="*.jar"/>
</path>
<!-- Convert jar collection from a given reference into one list, storing the result into a given property, separated by colon -->
<pathconvert pathsep=":" property="test.classpath" refid="classpath_jars"/>
</target>
<target name="loadTestNG" depends="setClassPath">
<!-- Creating task definition for TestNG task -->
<taskdef resource="testngtasks" classpath="${test.classpath}"/>
</target>
<target name="init">
<!-- Creating build directory structure used by compile -->
<mkdir dir="${build.dir}"/>
</target>
<target name="clean">
<echo message="deleting existing build directory"/>
<delete dir="${build.dir}"/>
</target>
<!-- In compile target dependency is given over clean target followed by init,
this order makes sure that build directory gets created before compile takes place
This is how a clean complile is achieved.
-->
<target name="compile" depends="clean,init,setClassPath,loadTestNG">
<echo message="classpath:${test.classpath}"/>
<echo message="compiling..."/>
<javac destdir="${build.dir}" srcdir="${src.dir}" classpath="${test.classpath}"/>
</target>
<target name="run" depends="compile">
<!-- testng classpath has been provided reference of jar files and compiled classes
this will generate report NG report.
-->
<testng classpath="${test.classpath}:${build.dir}" outputdir="${basedir}/output" haltonfailure="false" useDefaultListeners="true" listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter" classpathref="reportnglibs">
<xmlfileset dir="${basedir}" includes="testng.xml"/>
<!-- This value here will show the title of the report -->
<sysproperty key="org.uncommons.reportng.title" value="Example Test Report"/>
</testng>
</target>
</project>
Here is my TestNG.xml file:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Example Test Suite">
<test name ="Example TestCase Name">
<classes>
<class name="packageName.JavaFilename"></class>
</classes>
</test>
</suite>
I've found my answer on this site. I need to use maven to call my solution.
http://rationaleemotions.wordpress.com/2012/05/14/continuous-integration-with-selenium/
but thanx anyway for your help

when I run Ant in cmd it is showing me error of build.xml not exist while I have build.xml file in my project folder

I am a selenium user trying to generate xslt reports using Ant, but when I run Ant in cmd it is showing me error of build.xml not exist while I have build.xml file in my project folder.
I am using eclispe juno on windows 7 and and kept the build.xml file under the project.
I have java JDK1.7 on my machine and I have already set the environment variables(Java and ant both) as per instructions given on apache.org
Ant version is apache-ant-1.9.1
I have imported all necessary jar files (selenium + maven +saxon + all required for xslt report through ant) in my project in eclipse.
When I am trying to run ant through cmd it is showing me this error:-
BUILD FAILED
D:\Projects\Project\Selenium\Workspace\build.xml:70: Compile failed; see the compiler error output for details.
Below is my build.xml file:-
<project name="Plumslice" default="usage" basedir=".">
<property environment="env"/>
<property name="ws.home" value="${basedir}"/>
<property name="ws.jars" value="D:\All jars"/>
<property name="test.dest" value="${ws.home}/build"/>
<property name="test.src" value="${ws.home}/src"/>
<property name="ng.result" value="test-output"/>
<!--target name="start-selenium-server">
<java jar="${ws.home}/lib/selenium-server.jar"/>
</target-->
<target name="setClassPath" unless="test.classpath">
<path id="classpath_jars">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>
<pathconvert pathsep=":"
property="test.classpath"
refid="classpath_jars"/>
</target>
<target name="init" depends="setClassPath">
<tstamp>
<format property="start.time" pattern="MM/dd/yyyy hh:mm aa" />
</tstamp>
<condition property="ANT"
value="${env.ANT_HOME}/bin/ant.bat"
else="${env.ANT_HOME}/bin/ant">
<os family="windows" />
</condition>
<taskdef name="testng" classpath="${test.classpath}"
classname="org.testng.TestNGAntTask" />
</target>
<!-- all -->
<target name="all">
</target>
<!-- clean -->
<target name="clean">
<delete dir="${test.dest}"/>
</target>
<!-- compile -->
<target name="compile" depends="init, clean" >
<delete includeemptydirs="true" quiet="true">
<fileset dir="${test.dest}" includes="**/*"/>
</delete>
<echo message="making directory..."/>
<mkdir dir="${test.dest}"/>
<echo message="classpath------: ${test.classpath}"/>
<echo message="compiling..."/>
<javac
debug="true"
destdir="${test.dest}"
srcdir="${test.src}"
target="1.7"
classpath="${test.classpath}">
</javac>
<copy todir="${test.dest}">
<fileset dir="${test.src}" excludes="**/*.java"/>
</copy>
</target>
<!-- build -->
<target name="build" depends="init">
</target>
<!-- run -->
<target name="run" depends="compile">
<testng classpath = "${test.classpath}:${test.dest}" suitename = "suite1" >
<xmlfileset dir="${ws.home}" includes="testng.xml"/>
</testng>
<!--
<testng classpath="${test.classpath}:${test.dest}" groups="fast">
<classfileset dir="${test.dest}" includes="example1/*.class"/>
</testng>
-->
</target>
<target name="usage">
<echo>
ant run will execute the test
</echo>
</target>
<path id="test.c">
<fileset dir="${ws.jars}" includes="*.jar"/>
</path>
<target name="email" >
<java classname="com.qtpselenium.util.SendMail" classpath="${test.dest}" classpathref="test.c" />
</target>
<target name="makexsltreports">
<mkdir dir="${ws.home}/XSLT_Reports/output"/>
<xslt in="${ng.result}/testng-results.xml" style="src/com/testing/xslt/testng-results.xsl"
out="${ws.home}/XSLT_Reports/output/index.html" classpathref="test.c" processor="SaxonLiaison">
<param name="testNgXslt.outputDir" expression="${ws.home}/XSLT_Reports/output/"/>
<param name="testNgXslt.showRuntimeTotals" expression="true"/>
</xslt>
</target>
</project>
Thanks you all for your great help, I have resolved that error ..
It was related to the path of the jar files , I provided incorrect path to the jars.
This was line 70 : -
<javac debug="true" destdir="${test.dest}" srcdir="${test.src}"
target="1.7" classpath="${test.classpath}">
this is related to the path to the jars and in the top line of my file I did provided this path - D:\All jars , while all required jars was not in this folder, now I updated the jar folder and it is working fine now.

Ant not running all targets

I have the following ant file that is not running the targets "prepForDeployment" and "deployToStaging". This task is being run by Jenkins and I'm not getting any build errors when I look at the console output of the test.
<?xml version="1.0" encoding="UTF-8"?>
<project name="deploy" default="runUnitTests" basedir=".">
<description>
Deploys to staging.
</description>
<target name="init">
<taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask" classpathref="project.classpath" />
<!-- dump the properties -->
<echoproperties prefix="test" />
</target>
<target name="clean" depends="init">
<mkdir dir="${test.junitoutput}" />
</target>
<target name="runUnitTests" depends="init,prepForTests">
<mkdir dir="${test.output.xml}/unit" />
<runTestDirectory directoryName="." excludes=""/>
</target>
<target name="runAllTests" description="Make output directories and run the MXUnit task" depends="init,clean,runUnitTests">
<!-- generate pretty reports -->
<antcall target="junitreport" />
<fail if="tests.bombed" message="Failing the build due to test failures"/>
</target>
<target name="junitreport" depends="init" description="Runs the report without running the tests">
<junitreport todir="${test.junitoutput}">
<fileset dir="${test.output.xml}">
<include name="*.xml" />
</fileset>
<report format="frames" todir="${test.junitoutput}" />
</junitreport>
</target>
<target name="prepForTests">
<!-- just a bunch of replace tasks, runs OK -->
</target>
<target name="prepForDeployment" depends="init">
<replace file="Application.cfc">
<replacetoken>dbcreate="dropcreate"</replacetoken>
<replacevalue>dbcreate="update"</replacevalue>
</replace>
<replace file="Application.cfc">
<replacetoken>logSQL = true</replacetoken>
<replacevalue>logSQL = false</replacevalue>
</replace>
<echo message="Prepping for deployment done." />
</target>
<target name="deployToStaging" depends="prepForDeployment">
<sequential>
<!--copy the files to a temp directory-->
<copy todir="${staging}_temp" overwrite="true">
<!-- -->
</copy>
<!-- delete applicaiton files on staging -->
<delete quiet="true" includeemptydirs="true">
<fileset dir="${staging}" />
</delete>
<!-- copy files from temp dir to application dir -->
<copy todir="${staging}" overwrite="true">
<fileset dir="${staging}_temp" />
</copy>
<!-- remove temp dir -->
<delete quiet="true" includeemptydirs="true">
<fileset dir="${staging}_temp" />
</delete>
</sequential>
<echo message="The files have been copied to staging." />
</target>
<macrodef name="runTestDirectory">
<attribute name="directoryName"/>
<attribute name="excludes" default=""/>
<sequential>
<mxunittask server="${test.server}" port="${test.serverport}" defaultrunner="${test.runner}" outputdir="${test.output.xml}/#{directoryName}" verbose="true" failureproperty="tests.bombed" errorproperty="tests.bombed">
<directory path="${test.dir.location}/#{directoryName}" recurse="true" packageName="${test.cfcpath}.#{directoryName}" componentPath="${test.cfcpath}.#{directoryName}" excludes="#{excludes}" />
</mxunittask>
</sequential>
</macrodef>
</project>
If you're not telling Jenkins to run the prepForDeployment and deployToStaging targets then it won't run them, just the same as when you run Ant on the command line.
If you want those targets to run, add them to the target list under your "Invoke Ant" build step.

Javadoc errors when building Ant project

I am trying to write a build.xml file for my project. When I run build.xml as an Ant project, I get the following error:
D:\workspace\LogAlerter\src\com\j32bit\alerter\launcher\LogAlerter.java:9:
error: package org.apache.log4j does not exist
[javadoc] import org.apache.log4j.Logger;
I have imported log4j in LogAlerter.Java. Here is my build.xml file:
<?xml version="1.0"?>
<project name="LogAlerter" default="main" basedir=".">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<property name="dist.dir" location="dist" />
<property name="docs.dir" location="docs" />
<property name="libs.dir" location="lib" />
<!--
Create a classpath container which can be later used in the ant task
-->
<path id="build.classpath">
<fileset dir="${libs.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- Deletes the existing build, docs and dist directory-->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${docs.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Creates the build, docs and dist directory-->
<target name="makedir">
<mkdir dir="${build.dir}" />
<mkdir dir="${docs.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<!-- Compiles the java code (including the usage of library for JUnit -->
<target name="compile" depends="clean, makedir" >
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="build.classpath" includeantruntime="false">
</javac>
</target>
<!-- Creates Javadoc -->
<target name="docs" depends="compile">
<javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
<!-- Define which files / directory should get included, we include all -->
<packageset dir="${src.dir}" defaultexcludes="yes">
<include name="**" />
</packageset>
</javadoc>
</target>
<!--Creates the deployable jar file -->
<target name="jar" depends="compile">
<jar destfile="${dist.dir}\LogAlerter.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="LogAlerter.Main" />
</manifest>
</jar>
</target>
<target name="main" depends="compile, jar, docs">
<description>Main target</description>
</target>
</project>
Try adding a classpath ref to your javadoc task:
<javadoc packagenames="src"
sourcepath="${src.dir}"
destdir="${docs.dir}"
classpathref="build.classpath">
What the warning is telling you is that you've not provided the full classpath to the javadoc task. Try adding a similar classpath ref to that in your compile task and see where that leads.
Importing is fine but make sure it is available at run time for the JavaDoc tool. log4j.jar should be present in your build.classpath.
Make use of the classpathref inside the docs target like so:
<javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}" classpathref="build.classpath">

Resources