ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Duffey, Kevin" <>
Subject RE: How to handle conditional capabilities?
Date Mon, 31 Mar 2003 16:55:21 GMT
Hi Erik,

That sounds pretty close. Ideally, in a programmatic way I would have each little piece in
its own separate module, then call them however I wish, assembling the final "build" process
in a custom manner. For example, a target for make and build, where make would simply compile
classes and package up .jar files as necessary, but build would delete all compiled classes,
jar files, then do a full compile, then package up everything. I'd almost see it as a hierarchy
of targets. The default target is the one that "controls" everything, and always runs. Ideally
I'd like to be able to do something like:

if (build)
  <antcall target="init"/>
  <antcall target="clean"/>
  <antcall target="compile"/>
  <antcall target="build"/>
  <antcall target="package"/>
  <antcall target="deploy"/>
else if (make)
  <antcall target="compile"/>
  <antcall target="package"/>

Basically that is what I was hoping I could do, with of course a few variations on the above
for specific project needs.

So, is this possible without resorting to 3rd party .jar files (<script tag, etc)? It seems
to me my best bet is to just call EVERY target and have them all have if="" parameters, and
within some targets set properties at the end of completion and no errors. Is there a tag
that surrounds a target and can set or reset a property depending on if the target succeeded
or not?


-----Original Message-----
From: Erik Price [] 
Sent: Monday, March 31, 2003 8:14 AM
To: Ant Users List
Subject: Re: How to handle conditional capabilities?

Duffey, Kevin wrote:
> Hi all,
> I am using Eclipse 2.1 (just released) and Ant 1.5.1. I have like 8 build scripts, one
for development, one for a clean build, one to build and package, and so forth. What I would
like to do is consolidate into one build file since most of the build files are the same.
I am fairly familiar with the basics of ant as I have been using it for a few years. I haven't
done anything like what I want to do now. Basically, I want to be able to pass in some parameters
that set properties. I may have something like:
> <property name="version" value="1.2"/>
> <property name="build.type" value="clean"/>
> What I would like to do is somehow something like:
> If (build.type == "clearn")
> {
>   <delete all dirs>
> }
> else if (build.type == "dev")
> {
>   <compile only changes>
> }
> the properties, the compiling of source, etc is the same for all my build files so either
a single build file, or perhaps some links to how to make pretty solid build scripts for different
types of builds would be very helpful.

There seems to be two ways to do this if I understand you correctly. 
One way is to do exactly what you propose by setting properties on the 
command line or in files and using the "if" attribute 
of many of the tasks to conditionally execute them.

But it seems more like you would want to create a separate target for 
each of these goals, and then simply specify the target you wish to 
execute from the command line (?).  Am I just not understanding the 


To unsubscribe, e-mail:
For additional commands, e-mail:

Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.463 / Virus Database: 262 - Release Date: 3/17/2003

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.463 / Virus Database: 262 - Release Date: 3/17/2003

The information contained in this e-mail message may be 
confidential and  protected from disclosure. If you are 
not the intended recipient, any dissemination, distribution
or copying is strictly prohibited. If you think that you 
have received this e-mail message in error,
please e-mail the sender at

View raw message