Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2008

Tip: Looking for answers? Try searching our database.

Arguments with ANT

Thread view: 
Eric Farraro - 07 Apr 2008 18:05 GMT
I've been looking for a way to pass arguments to ANT, but have so far
been unsuccessful.  I figured out how to pass them from the command
line:

ant -buildfile -Dmyarg=abc

... but what I'd like to do, is have an ANT script call a different
ANT script, and pass the arguments along.  So far, I have not figured
out how to pass arguments to an ANT script, from within another ANT
script.  What I have is something like this:

(Inside build.xml):

<ant  dir="${ant.exec.directory}"  antfile="${ant.script.name}"
target="main"  inheritAll="true"/>

I'd like to pass any arguments to 'ant.script.name' that 'build.xml'
receives.  For instance, if there was a 'parameter' attribute, I could
use something like that.

Any suggestions?
Roedy Green - 07 Apr 2008 19:47 GMT
On Mon, 7 Apr 2008 10:05:39 -0700 (PDT), Eric Farraro
<superpeon1@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>... but what I'd like to do, is have an ANT script call a different
>ANT script, and pass the arguments along.  So far, I have not figured
>out how to pass arguments to an ANT script, from within another ANT
>script.  What I have is something like this:

You can put things in the set environment.  I put the jar signing
password in there, for example.

I get at it like this:

 <!-- get _your_ password from set jarsignerpassword=sesame -->
 <!-- get _your_ code-signing certificate from set
cert=mindprodcert2008dsa -->
 <property environment="env" />
 <signjar jar="${jar.file}"
   alias="${env.cert}" storepass="${env.jarsignerpassword}" />

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Arne Vajhøj - 08 Apr 2008 01:16 GMT
> I've been looking for a way to pass arguments to ANT, but have so far
> been unsuccessful.  I figured out how to pass them from the command
[quoted text clipped - 15 lines]
> receives.  For instance, if there was a 'parameter' attribute, I could
> use something like that.

inheritAll="true" will pass all existing properties.

To pass new properties use:

<ant  dir="${ant.exec.directory}"  antfile="${ant.script.name}"
target="main"  inheritAll="true">
   <property name="myarg" value="abc"/>
</ant>

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.