ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Krause <...@snafu.de>
Subject antcall and <target if="${xxx}"/>
Date Sun, 15 Feb 2009 23:42:53 GMT
Hello,

I recognized some strange behavior while calling a conditional target
with <antcall/>. The goal was a switch between different build modes.
Here's the code:

<project name="test" default="generate" basedir=".">
	<property name="build_mode" value="foo"/>
	<!--  -->
	<target name="init">
		<condition property="build_bar">
			<equals arg1="${build_mode}" arg2="bar" casesensitive="yes" trim="yes"/>
		</condition>
		<echo message="...  property build_bar: ${build_bar}"/>
		<condition property="build_foo">
			<isfalse value="${build_bar}"/>
		</condition>
		<echo message="...  property build_foo: ${build_foo}"/>
	</target>
	<!--  -->
	<target name="generate" depends="init">
		<echo>generate ...</echo>
		<antcall target="generate_foo"/>
		<antcall target="generate_bar"/>
		<echo>finished.</echo>
	</target>
	<!--  -->
	<target name="generate_foo" if="${build_foo}" depends="init">
		<echo>generate foo ...</echo>
	</target>
	<!--  -->
	<target name="generate_bar" if="${build_bar}" depends="init">
		<echo>generate bar ...</echo>
	</target>
</project>

The target "generate_foo" is skipped, with the verbose option I get the
follwing lines:

...
     [echo] ...  property build_foo: true

generate_foo:
Skipped because property 'true' not set.
...

Is this a bug or a feature?

(I can solve my problem by rearranging the tasks, but I'm interested in
 an explanation.)

Stefan

----

Here's the whole verbose output:

Apache Ant version 1.7.1 compiled on June 27 2008
Buildfile: build.xml
Detected Java version: 1.6 in: C:\Programme\Java\jdk1.6.0_04\jre
Detected OS: Windows XP
parsing buildfile C:\temp\build.xml with URI = file:/C:/temp/build.xml
Project base dir set to: C:\temp
[antlib:org.apache.tools.ant] Could not load definitions from resource
org/apache/tools/ant/antlib.xml. It could not be found.
Build sequence for target(s) `generate' is [init, generate]
Complete build sequence is [init, generate, generate_bar, generate_foo, ]

init:
Property "build_bar" has not been set
     [echo] ...  property build_bar: ${build_bar}
Property "build_bar" has not been set
     [echo] ...  property build_foo: true

generate:
     [echo] generate ...
Project base dir set to: C:\temp
  [antcall] calling target(s) [generate_foo] in build file C:\temp\build.xml
parsing buildfile C:\temp\build.xml with URI = file:/C:/temp/build.xml
Project base dir set to: C:\temp
Override ignored for property "build_mode"
Build sequence for target(s) `generate_foo' is [init, generate_foo]
Complete build sequence is [init, generate_foo, generate, generate_bar, ]
  [antcall] Entering C:\temp\build.xml...
Build sequence for target(s) `generate_foo' is [init, generate_foo]
Complete build sequence is [init, generate_foo, generate, generate_bar, ]

init:
Property "build_bar" has not been set
     [echo] ...  property build_bar: ${build_bar}
Property "build_bar" has not been set
Override ignored for property "build_foo"
     [echo] ...  property build_foo: true

generate_foo:
Skipped because property 'true' not set.
  [antcall] Exiting C:\temp\build.xml.
Project base dir set to: C:\temp
  [antcall] calling target(s) [generate_bar] in build file C:\temp\build.xml
parsing buildfile C:\temp\build.xml with URI = file:/C:/temp/build.xml
Project base dir set to: C:\temp
Override ignored for property "build_mode"
Build sequence for target(s) `generate_bar' is [init, generate_bar]
Complete build sequence is [init, generate_bar, generate, generate_foo, ]
  [antcall] Entering C:\temp\build.xml...
Build sequence for target(s) `generate_bar' is [init, generate_bar]
Complete build sequence is [init, generate_bar, generate, generate_foo, ]

init:
Property "build_bar" has not been set
     [echo] ...  property build_bar: ${build_bar}
Property "build_bar" has not been set
Override ignored for property "build_foo"
     [echo] ...  property build_foo: true

generate_bar:
Property "build_bar" has not been set
Property "build_bar" has not been set
Property "build_bar" has not been set
Skipped because property '${build_bar}' not set.
  [antcall] Exiting C:\temp\build.xml.
     [echo] finished.

BUILD SUCCESSFUL
Total time: 0 seconds

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message