ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Anson <dan...@germane-software.com>
Subject Re: Difficulty with "unless" attribute
Date Fri, 13 Jun 2003 00:16:15 GMT
That's not quite right. If the "init" target is listed as a dependency 
of another target, the property will be available to the first target. 
This example works as expected, that is, the "first" target will print 
out the buildstamp:

<target name="first" depends="init">
    <echo>${buildstamp}</echo>
</target>

<target name="init" unless="buildstamp">
    <tstamp>
       <format property="buildstamp" pattern="yyyyMMdd-HHmm"/>
    </tstamp>
    <property name="buildstamp" value="blah"/>
</target>

Dale Anson


Matt Reason wrote:

>Because you set the property in a target, it is invisible to other
>targets.
>
>If you call another target in from this target with the
>inheritall="true", it will be visible to the children.
>
><target name="init" unless="buildstamp">
>	<tstamp>
>		<format property="buildstamp" pattern="yyyyMMdd-HHmm"/>
>	</tstamp>
>	<property name="buildstamp" value="blah"/>
>	<ant target="echo_buildstamp" inheritall="true"/>
></target>
><target name="echo_buildstamp">
>	<echo message="buildstamp is ${buildstamp}."/>
></target>
>
>Another thing you can do is have this target in it's own build.xml and
>have it write the property to a file (using the replace task) and then
>in the main build.xml, load that property file.
>
>Matt
>
>-----Original Message-----
>From: Maurer, Justin [mailto:jmaurer@defywire.com] 
>Sent: Thursday, June 12, 2003 8:40 AM
>To: user@ant.apache.org
>Subject: Difficulty with "unless" attribute
>
>
>Greetings,
>
>	Much FAQ-reading and Google searching has led me here. I'm
>having some difficulty with the "unless" attribute of the <target> task.
>I have a target, currently named init, with the sole purpose of setting
>a property to be used as a buildstamp. Presently, it looks like this:
>
><target name="init" unless="buildstamp>
>	<tstamp>
>		<format property="buildstamp" pattern="yyyyMMdd-HHmm"/>
>	</tstamp>
>	<property name="buildstamp" value="blah"/>
></target>
>
>(the <property name...> doesn't affect the results - i put it in just to
>be sure the property was being set...). I can refer to ${buildstamp}
>later in the file, once this target has been executed, but this target
>_keeps_ getting run, and buildstamp keeps getting changed (the
>lowest-level module we have depends on init, other resources depend on
>this module..).
>
>Thanks for any assistance, my sincerest apologies if I've asked a silly
>question (I checked the FAQs!)!
>
>
>Justin Maurer
>Software Configuration Engineer
>Defywire, Inc.
>Direct:  
>Mobile: 
>Fax: 
>
>Email: jmaurer@defywire.com
>
>"Enabling the Enterprise"
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>  
>


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


Mime
View raw message