ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nico Seessle" <n...@seessle.de>
Subject Re: Using "if" in a target?
Date Sun, 17 Sep 2000 21:21:17 GMT
----- Original Message -----
From: "Diane Holt" <holtdl@yahoo.com>
To: <ant-user@jakarta.apache.org>
Sent: Sunday, September 17, 2000 10:52 PM
Subject: Using "if" in a target?


> Am I using "if" correctly in this target:
>   <target name="nsync" if="p4client">
>     <exec executable="p4" dir="${workspace}">
>       <arg value="sync -n ${spec}"/>
>     </exec>
>   </target>

Yes.

> I have another target that depends on nsync, which I assumed would mean
> "If nsync doesn't get run (or if it runs but fails), don't run this one"

I'm not totally sure, but I don't think so (for assumption 1.). Each target
checks it's own conditions. I have not seen any source which checks if a
target which the current one depends on executed.

If the target "fails" the build will be completely stopped. Just depends on
your definition of failure :-)

> -- and I assumed if the property in the "if" in nsync wasn't set, then
> nsync wouldn't get run. The target that depends on nsync is just a little

Correct.

> stubbed-off echo (for now):
>   <target name="build" depends="nsync">
>     <echo message="Running build target..."/>
>   </target>
>
> I explicitly unset the env var that the p4client property is passed in the
> ant wrapper-script (ie., "$JAVACMD ... -Dp4client=$P4CLIENT ...") so that
> the property wouldn't have a value. The output from the check_properties
> target shows that p4client isn't set, as does the fact and type of the
> error from the command that nsync went ahead and executed anyway:

And p4client is set to "" (You can verify this in a simple way, just specify
a property you are sure you have never used before as for example
"donaudampfschiffahrtskapitaen" (german :-) ). You will see that ant just
echoes the property. In your case there is nothing which means the property
exists, but it is empty (which in turn is enough to get a target run)).

> [binky] ant check_properties build
> Buildfile: build.xml
> check_properties:
>   p4client is:
> nsync:
>      [exec] Client 'binky' unknown - use 'client' command to create it.
>      [exec] Result: 1
> build:
>   Running build target...
>

You can specify failonerror="yes" to the exec-task and your build will fail
completely.

> I'm running the nightly from 9/16. (But it behaves the same with the
> nightly back from 9/9.)

It will behave the same with the current version in CVS.

Nico



Mime
View raw message