ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@ca.ibm.com
Subject Re: References do not work for me.
Date Thu, 16 Nov 2000 22:48:41 GMT


Its not that references aren't working for you, its that you are using an
older mechanism for setting properties that is discouraged.  Other people
are having this problem.

Try this:

<project ...>
  <!-- properties don't have to be in targets -->
  <property name="myprop" value="foo/bar" />

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

  ...
</project>

I haven't tested it, so YMMV, but like I said in the other email, this
should work.

Glenn McAllister
Software Developer. IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the
right answer to the wrong question." - John W. Tukey


Please respond to ant-dev@jakarta.apache.org

To:   "'ant-dev@jakarta.apache.org'" <ant-dev@jakarta.apache.org>
cc:
Subject:  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 <jhempe@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
>




Mime
View raw message