You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by John Cleary <jo...@innovit.com> on 2000/09/26 08:01:59 UTC

perhaps silly question RE Project.setProperty()

Hi there,

I'm trying to write my own task that creates a string and then places it in
a property that will be readable from build.xml

The code snippet that I have in my execute() that plays with the properties
is:

	if (project.getProperty(destPropertyName) == null) {
		project.setProperty(destPropertyName, result.toString());
	} else {
		log("Override ignored for " + destPropertyName);
	}

The xml snippet from build.xml is

	<target name="prepareClasspath" depends="cvsCheckout">
	  	<pathAssemble file="${projectInfoFile}" basePropertyName="lib"
	  		baseDirectory="${libDir}" seperator=":" destPropertyName="jclibs"/>
	  	<echo message="classpath: ${jclibs}" />
	  	<property name="jclibs" value="${jclibs}:${srcDir}" />
	</target>

When I print out ${jclibs} in the xml, it doesn't have a value.

I've tried playing with setUserProperty as well, but that didn't seem to
make any difference..

Argghhhh, any ideas?

John.


Re: perhaps silly question RE Project.setProperty()

Posted by Stefan Bodewig <bo...@bost.de>.
John, your problem is that before Ant 1.2alpha2 ${} expansion is being
performed by the parser, i.e. before your task's execute method has
been called.

Up from Ant 1.2alpha2 your snippet should work. If using Ant 1.1 move
the code from execute to init (this is what <property>, <available>
and others did themselves).

Stefan