You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David Adams <DA...@ignitesports.com> on 2002/08/02 00:14:24 UTC

Target/unless not working

I am attempting to manage build dependencies by setting a property in a target and then filtering on that property using "unless", which should avoid running that target since the property was set. 

Below is an example of the code I am trying:
<project name="masterbuild" default="main" basedir=".">
	<target name="init">
		<echo message="init"/>
	</target>

	<target name="first" depends="init" unless="first_built">
		<echo message="first"/>
		<property name="first_built" value="true"/>
		<echo message="${first_built}"/>

	</target>

	<target name="second" unless="second_built" depends="first">
		<echo message="${first_built}"/>
		<property name="second_built" value="true"/>

	</target>
	
	<target name="main">
		<antcall target="first"/>
		<antcall target="second"/>
	</target>
    
</project>

My output is:
main:

init:
     [echo] init

first:
     [echo] first
     [echo] true

init:
     [echo] init

first:
     [echo] first
     [echo] true

second:
     [echo] true

BUILD SUCCESSFUL
Total time: 9 seconds

The expectation is that "second" runs without going into "first".

Thoughts?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Adams
Ignite Sports (www.ignitesports.com)
Voice: 773.293.4300
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~