ant - taskdef class org.testng.TestNGAntTask cannot be found -


i'm trying ant compile , keep getting:

taskdef class org.testng.testnganttask cannot found

most examples see have in classpath: ${libs.dir}/testng-6.8.jar

i tried:

<taskdef name="testng" classpath="${test.classpath}"     classname="org.testng.testnganttask" /> 

parts of build.xml

<property environment="env"/> <property name="ws.home" value="${basedir}"/> <property name="ws.jars" value="c:\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="setclasspath" unless="test.classpath">     <path id="classpath_jars">         <fileset dir="${ws.jars}" includes="*.jar"/>     </path>     <pathconvert pathsep=":" property="test.classpath" refid="classpath_jars"/> </target> 

what path should use , how know version of testng.jar have

enter image description here screenshot of eclipse environment

if compile -v, get:

[echo] classpath------: c:\jars\testng.jar 

i copied testng.jar directory , still no luck.

try using path reference, instead of property, when creating task. example:

<path id="classpath_jars">   <fileset dir="${ws.jars}" includes="*.jar"/> </path>  <taskdef name="testng" classpathref="classpath_jars" classname="org.testng.testnganttask" /> 

future consideration

what path should use , how know version of testng.jar have

have considered adding maven style dependency management build? give more certainty jars being used build process you've requested. stands, relying on manual configuration correct jar placed in expected directory.

dependency management capability provided apache ivy plugin. provides additional tasks enable manage classpaths via jars automatically downloaded , cached central maven repository.

for example:

 <ivy:cachepath pathid="build.path">      <dependency org="org.testng" name="testng" rev="6.11" conf="default"/>  </ivy:cachepath>   <taskdef name="testng" classpathref="build.path" classname="org.testng.testnganttask" /> 

the following more complete example demonstrates how ant can configured setup ivy plugin automatically, making build portable across machine. need java , ant installed.

build.xml

<project name="demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">      <!--     ================     build properties     ================     -->     <available classname="org.apache.ivy.main" property="ivy.installed"/>       <!--     ==========     build main     ==========     -->      <target name="build" depends="install-ivy">          <ivy:cachepath pathid="build.path">              <dependency org="org.testng" name="testng" rev="6.11" conf="default"/>          </ivy:cachepath>           <taskdef name="testng" classpathref="build.path" classname="org.testng.testnganttask" />     </target>      <!--     ===========     build setup     ===========     -->     <target name="install-ivy" description="install ivy" unless="ivy.installed">         <mkdir dir="${user.home}/.ant/lib"/>         <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/>         <fail message="ivy has been installed. run build again"/>     </target>   </project> 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -