You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Frederick N. Brier" <fb...@multideck.com> on 2001/08/19 03:22:26 UTC
javac classpath element not behaving (1.4beta)
I am doing something that several postings have talked about, and that is
having a dependent target build on a .jar created by a preceding target. I
tried to use the refid mechanism, and then use the <javac>'s <classpath>
element to append the dist/lib path in subsequent targets. This was so
that the path evaluation would be delayed until that target was
compiled. My approach appears to be flawed however because rather than
reference the .jar files in the path, it is rebuilding the class files and
including them in each jar file. I've tried to calculate the classpath
used in the javac task and then echo it, but it is echo'ing the property
name, not the classpath I would presume would have been stored. Now I
understand that this was a bug/missing feature in 1.3, and apparently has
been added and is working in the 1.4beta. So I downloaded the 1.4beta and
tried it and received the same results. And I checked that I really was
running the 1.4beta. Could someone please tell me what I am
overlooking? The beginning of the build.xml file has this:
<path id="app.class.path">
<pathelement location="lib/"/>
<fileset dir="../lib">
<include name="**/*.jar"/>
</fileset>
</path>
The first target looks like this and works fine:
<property name="path.util" refid="app.class.path"/>
<echo>${path.util}</echo>
<javac srcdir="${src}" destdir="${build-app-util}"
verbose="${compile.verbose}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
includes="com/mycompany/util/class1.java,
com/mycompany/util/class2.java"
classpathref="app.class.path"
/>
The first two elements are for debugging the build.xml and outputs the
expected results:
compile-app-util:
[echo]
c:\dev\myapp\src\lib;c:\dev\myapp\lib\servlet.jar;c:\dev\myapp\lib\jboss\jmxri.jar;c:\dev\myapp\lib\jboss\jndi.jar;c:\dev\myapp\lib\jboss\jboss.jar;c:\dev\myapp\lib\jboss\log4j.jar;c:\dev\myapp\lib\jboss\jboss-jdbc_ext.jar;c:\dev\myapp\lib\castor-0.9.3.jar;c:\dev\myapp\lib\xerces.jar;c:\dev\myapp\lib\mm.mysql-2.0.4-bin.jar;c:\dev\myapp\lib\javax.jar;c:\dev\myapp\lib\struts.jar
[javac] Compiling 2 source files to c:\dev\myapp\build\app-util
The subsequent target has the following debugging statements and javac
task. Note the use of the classpath element in the javac task
element. This should work, no?
<property name="model-class-path">
<classpath>
<path refid="app.class.path"/>
</classpath>
</property>
<echo>${model-class-path}</echo>
<property name="model-dist-path">
<classpath>
<pathelement location="dist/lib/"/>
</classpath>
</property>
<echo>${model-dist-path}</echo>
<property name="model-path">
<classpath>
<pathelement location="dist/lib/"/>
<path refid="app.class.path"/>
</classpath>
</property>
<echo>${model-path}</echo>
<javac srcdir="${src}" destdir="${build-app-model}"
verbose="${compile.verbose}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
includes="com/mycompany/app/appclass1.java,
com/mycompany/app/appclass2.java,
com/mycompany/app/appclass3.java">
<classpath>
<pathelement location="dist/lib/"/>
<path refid="app.class.path"/>
</classpath>
</javac>
The output is as follows:
compile-app-model:
[echo] ${model-class-path}
[echo] ${model-dist-path}
[echo] ${model-path}
[javac] Compiling 3 source files to c:\dev\myapp\build\app-model
This is where I am really confused. Why is it echoing the ${property-name}
instead of its value. I have also tried the <echo
message="${property-name}"/> syntax with the same result.