You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by John Hempe <jh...@north.com> on 2000/11/16 22:12:25 UTC

References do not work for me.

References don't act nice like properties, there must be something about
them I'm not "getting".  Are they supposed to be working or is this feature
incomplete?

They don't expand right, and they simply don't work for me.  If the
following file is "test.xml":

<project name="testref" basedir=".">
<target name="init">
  <property name="myprop" value="foo/bar"/>
  <property name="ugly.class.path" value="this:that:the_other"/>
</target>

<path id="compile.class.path">
  <pathelement location="/${myprop}/baz"/>
  <pathelement location="/only/hardcoded/paths/work"/>
</path>

<target name="list" depends="init">
  <property name="transfer.compile.class.path" refid="compile.class.path"/>
  <echo message="CLASS PATH is ${transfer.compile.class.path}"/>
  <echo message="Ugly class path actually works and is:
${ugly.class.path}"/>
</target>
</project>

My output is as follows:

build >ant -version                                                 
Ant version 1.2 compiled on October 24 2000                         
                                                                   
build >ant -buildfile test.xml list                                 
Buildfile: test.xml                                                 
                                                                    
init:                                                               
                                                                    
list:                                                               
CLASS PATH is /${myprop}/baz:/only/hardcoded/paths/work             
Ugly class path actually works and is: this:that:the_other          
                                                                    
BUILD SUCCESSFUL                                                    
Total time: 0 seconds                                               

To add insult to injury, when I use a "javac" task in verbose mode, and
specify classpath by reference, I seem to get a class path that has nothing
whatsoever to do with the one I specified.
I'm referencing it correctly I believe:

<target name="compile" depends="init">
  <javac srcdir="path/to/my/classes"
	 debug="on">
    <classpath refid="compile.class.path"/>
  </javac>
</target>

If I use a version of this target with my test script listed above, invoked
with -verbose, I get:
    [javac] Compilation args: -d path/to/my/classes -classpath
/path/to/my/classes:/prefix/jakarta-ant/lib/ant.jar:/prefix/jakarta-ant/lib/
jaxp.jar:/prefix/jakarta-ant/lib/parser.jar:/opt/jdk1.2.1_04/lib/tools.jar
-sourcepath [path] -g                                           

This classpath looks a heckuvalot more like the path the Ant sh script uses
to invoke itself than what I referenced, which should be in the worst case
/${myprop}/baz:/only/hardcoded/paths/work  
And ideally:
/foo/bar/baz:/only/hardcoded/paths/work  

So my first question is, why don't properties in referentially defined paths
seem to expand correctly? 

The second one is, why don't referenced classpaths seem to work AT ALL for
me???

--John Hempe



                                                          

> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@bost.de]
> Sent: Thursday, November 16, 2000 12:36 AM
> To: ant-user@jakarta.apache.org
> Subject: Re: Debugging references
> 
> 
> John Hempe <jh...@north.com> wrote:
> 
> > So if I define something like:
> > 
> > <path id="compile.class.path">
> >   <pathelement location="${something}/classes"/>
> >   <pathelement location="${something.else}/classes"/>
> > </path> 
> > 
> > How can I "echo" what "compile.class.path" gets set to?  How can I
> > see it at runtime?
> 
> <snip/>
> 
> > I tried <echo message="${compile.class.path}"> but that doesn't
> > work,
> 
> Assign it to a property in between:
> 
> <property name="compile.class.path" refid="compile.class.path" />
> <echo message="${compile.class.path}">
> 
> ugly but it should work.
> 
> Stefan
>