File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes How do I pass parameters in Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How do I pass parameters in Ant " Watch "How do I pass parameters in Ant " New topic
Author

How do I pass parameters in Ant

Micky Morgan
Greenhorn

Joined: Sep 20, 2006
Posts: 19
I would run my JUnit tester like

java -classpath %CLASSPATH% -Dhostname=jetty -Dport=8080 org.junit.runner.JUnitCore com.thoughtworks.selenium.QATester

How would I convert this as ant script? the below script is not working at all. It shows hostnae and port as null???
----------------------
<target name="run" depends="start">
<java classname="org.junit.runner.JUnitCore">
<arg value="com.thoughtworks.selenium.Jasper"/>
<jvmarg value="-Dhostname=jetty"/>
<jvmarg value="-Dport=8080"/>


<classpath>
<pathelement location="C:\Selenium-RC\java\junit-4.1.jar"/>
<pathelement location="C:\Selenium-RC\java\b.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
</target>
Joy Mookerji
Ranch Hand

Joined: Jul 26, 2006
Posts: 49
Micky
Try the system property
<java>
<sysproperty key="hostname" value="jetty" />
<sysproperty key="port" value="8080" />

</java>


SCJP 5<br />Brainbench Certified in C++<br />PMP<br />Dallas,TX
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
From the ant manual on java task and Junit Task jvmarg may be used if fork is enabled.




[ September 22, 2006: Message edited by: Carol Enderlin ]
[ September 22, 2006: Message edited by: Carol Enderlin ]
Micky Morgan
Greenhorn

Joined: Sep 20, 2006
Posts: 19
Thanks Joy and Carol. Both of your suggestions works for me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I pass parameters in Ant
 
Similar Threads
ANT issues - Unable to create JUnit Reports- Please help
JUnit ant batch process failing
'junit' task problem
urgent help on passing parameters thru ant script
How to run JUNIT Tester with Ant