ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <>
Subject Re: Target unless question
Date Fri, 14 Aug 2009 11:30:44 GMT


Thanks - I know all this :)

I didn't go into much explanation - just simplified it down...

But, to be specific - I have this build environment with many empty 
targets that are later defined (by scripts who import this one) that do processing 
specific to the target - for example I have the following targets:

release-source.preprocess (empty target), release-source.process (has a 
default implementation to release source), (empty target) and finally release-source 
(depends on release-source.preprocess, release-source.process and 
release-source.postprocess).  I also like to include a SKIP property that 
if set, will skip a target.  I had the unless on, for example, 
the release-source target (hoping it'd skip the 3 depends)...

The idea with the pre/post process targets are - if you like the default 
implementation of process but need to add some additional functionality 
either before or after - one provides the targets accordingly.

Anyway - thanks for the reply - you always have great explanations :)


On Thu, 13 Aug 2009, David Weintraub wrote:

> On Thu, Aug 13, 2009 at 3:09 PM, Scot P. Floess <> wrote:
>> I was under the impression that using an unless attribute on a target will
>> not run the target if that property is set...  However, if there are is a
>> depends attribute defined, the targets in the depend are run regardless?
> Remember: Ant is not a programming language, but a build system that uses a
> dependency matrix to determine the build order. Unlike a programming
> language, you do not specify the actual build order of your targets.
> Instead, you merely state that one target depends upon another. Ant then
> uses this information to actually determine the build order. Ant builds this
> dependency matrix first before even looking at what is required to execute
> the targets.
> Your example, although is an excellent test, isn't that realistic since you
> are passing the "stop" property on the command line itself. More likely, the
> property is set by a previous dependent target execution.
> However, let's assume that I do want to use that property on the command
> line to determine whether or not to execute a specific target. Let's say
> that my build file looks like this:
> <project>
>    <target name="compile"/>
>    <target name="package
>        depends="compile"/>
>    <target name="compress"
>        unless="dont-compress"
>        depends="package"/>
>    <target name="deploy"
>        depends="compress"/>
> </project>
> In this example, I want to execute my "deploy" target. Normally, I want to
> do my compress step which removes debugging information from my software
> package.
> However, sometimes, for debugging purposes, I need to install my package
> with debugging information. I could execute this:
> $ ant -Ddont-compress deploy
> In this case, I do want to execute my "compile" and "package" targets before
> I do my deployment. However, I don't want the compress target to execute. If
> I pre-tested my property "dont-compress" and because of that, I decided not
> to execute my compile and package, the deploy target would fail.
> -- 
> David Weintraub

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-890-8117 (Work)

Chief Architect JPlate
Chief Architect JavaPIM

Architect Keros

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

View raw message