ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From KC Baltz <KBa...@responsenetworks.com>
Subject RE: setting properties from a User defined Task.
Date Mon, 07 Aug 2000 12:27:35 GMT
What you and Stephan have said makes sense and is what I would expect for
Ant 1.1.  But my version seems to be disagreeing.  Here's the basics of my
build.xml.

<project>
  <target name="init">
    <!-- Adds all the jars in a given directory to the target property -->
    <getjars target_property="jarClassPath"
basedir="${srcdir}\com\responsenetworks\lib" />
    <!-- Set the ClassPath using some hard coded values and the property we
just set. -->
    <property name="ClassPath"
value="d:\jdk1.3\jre\lib\rt.jar;d:\jdk1.3\jre\lib\jaws.jar;${jarClassPath}"
/>
    <!-- The following prints ClassPath with the dynamically generated
jarClassPath appended -->
    <echo message="classpath = ${ClassPath}" /> 
  </target>

  <target name="compile">
    <javac srcdir="${srcdir}" destdir="${builddir}" classpath="${ClassPath}"
.../>
  </target>
</project>

The getjars task is the one that uses project.setProperty.  But by what
you've been saying, it should be evaluated after any calls to <property> and
thus the echo should produce:

classpath =
d:\jdk1.3\jre\lib\rt.jar;d:\jdk1.3\jre\lib\jaws.jar;${jarClassPath}

But what it does in fact is produce:

classpath =
d:\jdk1.3\jre\lib\rt.jar;d:\jdk1.3\jre\lib\jaws.jar;foo.jar;bar.jar;my.jar..
..

What am I missing here?  Or is this a "bug/feature"?

K.C.




> -----Original Message-----
> From: Conor MacNeill [mailto:conor@cortexebusiness.com.au]
> Sent: Friday, August 04, 2000 11:52 AM
> To: ant-user@jakarta.apache.org
> Subject: RE: setting properties from a User defined Task.
> 
> 
> K.C.,
> 
> The init target is not special. All targets are treated equally. All
> property elements are evaluated at parse time regadless of 
> whether thay are
> scoped in the project or in a target.
> 
> For this reason most of my build files look like this
> <project>
>    <property ...>
>    <property ...>
> 
>    <target ...>
>       <task>
>    </target>
> </project>
> 
> It is cool to use project.setProperty and it is certainly 
> valid for a task
> to set properties. That propery value cannot, however, be 
> used in a ${}
> construct since property substitution has already occurred. 
> That property
> value can really only be used by other tasks that look up the 
> property in
> the project object. Have a look at the if and unless attributes on the
> target element. Notice that you don;t use the ${} syntax.
> 
> It is likely that property evaluation and replacement will be 
> changed so
> that it happens just prior to use rather than at parse time.
> 
> Cheers
> Conor
> 
> 
> > From: KC Baltz [mailto:KBaltz@responsenetworks.com]
> > Sent: Saturday, 5 August 2000 1:25
> > To: 'ant-user@jakarta.apache.org'
> > Subject: RE: setting properties from a User defined Task.
> >
> >
> > Conor,
> > Is the target "init" special?  Because I have a custom task to set a
> > property that does seem to work.  I am using the following version:
> > Ant version 1.1 compiled on July 18 2000
> >
> > I also call project.setProperty().
> >
> > With the new switch to immutable properties, is it now considered
> > bad/wrong
> > behavior for a custom task to set a property?
> >
> > K.C. Baltz
> >
> > > -----Original Message-----
> > > From: Conor MacNeill [mailto:conor@cortexebusiness.com.au]
> > > Sent: Tuesday, August 01, 2000 6:37 PM
> > > To: ant-user@jakarta.apache.org
> > > Subject: RE: setting properties from a User defined Task.
> > >
> > >
> > > Pablo,
> > >
> > > The problem is that the property substitution happens before
> > > any tasks are
> > > executed. Currently ant cannot do what you are asking.
> > > Perhaps you can tell
> > > us how you wish to use the ppp value. There may be other
> > > mechanisms within
> > > ant that you can use.
> > >
> > > Conor
> > >
> > > --
> > > Conor MacNeill
> > > conor@cortexebusiness.com.au
> > > Cortex eBusiness
> > > http://www.cortexebusiness.com.au
> > >
> > > > -----Original Message-----
> > > > From: Pablo Garralda [mailto:PGarralda@amtec.net]
> > > > Sent: Wednesday, 2 August 2000 5:15
> > > > To: ant-user@jakarta.apache.org
> > > > Subject: setting properties from a User defined Task.
> > > >
> > > >
> > > >
> > > > Hi !!
> > > >
> > > > I'm trying to build a user defined Task to store a directory
> > > > listing into a
> > > > Property.
> > > > Someting like this:
> > > >
> > > >   ...
> > > >   <target name="Test" depends="" >
> > > >       <dirlisting basedir="." includes="*.java" property="ppp"
> > > > separator=" "
> > > > />
> > > >       <echo message="Java files: ${ppp}" />
> > > >   </target>
> > > >   ...
> > > >
> > > > This prints:
> > > >
> > > >   Java files: ${ppp}
> > > >
> > > > It don't replace ${ppp} with "ppp" value!!! What's wrong?
> > > >
> > > > Thanks in advance,
> > > > 		Pablo.
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
> 

Mime
View raw message