0

How to include a Java command in ANT to run the project. I have searched the net and all examples creates a jar and then run it. I don'nt want to use a jar. I tried using below code, it is giving error that Java tag is not complete. My project is using TestNG so i need to give this command to run it - java -cp "/home/admin/A/":"/home/admin/A/lib/*" org.testng.TestNG testng.xml

My code is as below:

 <target name="run" depends="jar,compile,init">
<!-- <java jar="${jar.dir}/${ant.project.name}-${ant.version}.jar" -->

 <java -cp "/home/admin/A/I/S/out/production/S/":"/home/admin/A/I/State/lib/*" org.testng.TestNG testng.xml >
</java>

0

2 Answers 2

2

Use something like this:

<target name='run' depends="jar,compile,init"> <java classname="org.testng.TestNG" dir="." fork="true" failonerror="true" maxmemory="128m" > <classpath> <pathelement location='/home/admin/A/I/S/out/production/S/' /> <pathelement location='/home/admin/A/I/State/lib/*' /> </classpath> <arg value="testng.xml" /> </java> </target>

The second path element you can expand to individual JAR files in the lib folder or use a path and refer to it in the class path.

Sign up to request clarification or add additional context in comments.

Comments

0

The Java task page in the Ant Manual will help you create a correct Java tag. (Note that all content in an Ant build.xml file must be valid XML.)

However, you should probably look at use the testng Ant task in your build file, rather than executing via Java directly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.