ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ellsworth <sc...@alodar.com>
Subject Be careful with properties in an ANT task!
Date Tue, 14 May 2002 20:59:30 GMT
Beware!

This looks fine:

   <target name="main">
     <property name="allproject.dir" value="${basedir}/../../.."/>
     <ant inheritall="false" dir="${allproject.dir}/build" 
antfile="standard-build.xml" target="${project.target}">
       <property name="compile.library.classpath" 
value="oracle.jar,mysql.jar"/>
       <property name="jar.extra.library.zip" 
value="${compile.library.classpath}"/>
     </ant>
   </target>

but it WILL fail painfully - property statements inside an ant target 
will be set in the ant call, but are not set in the current context.  
(Obviously - how else could you refer to a property that will have the 
same name in both.)

Tracking this down can be quite a pain.  The big clue - in 
echo-properties, you will see something like:

[echoproperties] compile.library.classpath=oracle.jar,mysql.jar
[echoproperties] jar.extra.library.zip=${compile.library.classpath}

rather than the expected

[echoproperties] compile.library.classpath=oracle.jar,mysql.jar
[echoproperties] jar.extra.library.zip=oracle.jar,mysql.jar

Aargh!

My solution - the main target became:

   <target name="main">
     <property name="allproject.dir" value="${basedir}/../../.."/>
     <property name="compile.library.classpath" 
value="oracle.jar,mysql.jar"/>
     <ant inheritall="false" dir="${allproject.dir}/build" 
antfile="standard-build.xml" target="${project.target}">
       <property name="compile.library.classpath" 
value="${compile.library.classpath}"/>
       <property name="jar.extra.library.zip" 
value="${compile.library.classpath}"/>
     </ant>
   </target>

Scott


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


Mime
View raw message