You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by stephane vaucher <va...@LUB.UMontreal.CA> on 2002/01/23 19:11:07 UTC

java task and classpath

Hello everyone,

I have a problem using the nested references in nested <classpath>
attributes. Ant seems to refuse to accept classpaths like the following:

<classpath>
   <pathelement path="${project.classpath}"/>
</classpath>

In such a case, ant uses its own classpath (from executing
$ANT_HOME/bin/ant). If I add another element in the classpath such as:

<classpath>
   <pathelement path="${project.classpath}"/>
   <pathelement location="./lib/core.jar" />
</classpath>

Ant now only gives me a classpath with "./".

in a case without references, it works fine:

<classpath>
   <pathelement path="./classes"/>
   <pathelement location="./lib/core.jar" />
</classpath>

Ant now only gives me a classpath with "./".

I don't know if we can use the echo task to print out the content of
variables, so I wrote a simple Test class that prints out the classpath
(System.out.println("[java.class.path,"+System.getProperty("java.class.path")+"]");).
I haven't seen anyone with a similar problem in the mailing list except
maybe forked JVM's classpath not clean when using JUnit task. Since I
have no knowledge of JUnit, I'll assume fornow it's unrelated.

------------ ant execution script changes ----------------

# SV 2001/11/08
export JAVA_HOME=/usr/java
export CLASSPATH=$ANTCLASSPATH


------------- Code except --------------

<project name="NADIM" default="all" basedir=".">

 <!-- defines all of the homes -->
 <property file="build.properties" />

...

 <path id="project.classpath">
   <path refid="jini.path" />
   <path refid="weblogic.path" />
   <fileset dir="${lib}">
     <include name="**/*.jar"/>
   </fileset>
 </path>

...

 <target name="ejbmake">
   <!-- should be weblogic.ejbc20,
        Test only prints out the classpath
   -->
   <java classname="Test" fork="yes" >
      <sysproperty key="weblogic.home" value="${weblogic.home}"/>
      <arg value="-verbose"/>
      <arg value="${ejbtmp}"/>
      <arg value="${ejbjar}"/>
    <classpath>
    <pathelement path="${project.classpath}"/>
    </classpath>
  </target>

...
</project>


-------------- Environment ------------------
RedHat7.1
Ant 1.4.1
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)

Cheers,
Stephane Vaucher
Research Professional
CIRANO

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: java task and classpath

Posted by stephane vaucher <va...@LUB.UMontreal.CA>.
Thanks a lot, it seems to work.

Stephane

Diane Holt wrote:

> The "${}" format is used to reference properties -- when referencing id's,
> use the 'refid' attribute and just the name. Eg:
>   <classpath>
>     <path refid="project.classpath"/>
>     <pathelement location="./lib/core.jar"/>
>   </classpath>
>
> To echo the value of the id'd path, you can set a property for it:
>   <property name="project.classpath" refid="project.classpath"/>
>   <echo message="project.classpath = ${project.classpath}"/>
>
> Diane
>
> --- stephane vaucher <va...@LUB.UMontreal.CA> wrote:
> > Hello everyone,
> >
> > I have a problem using the nested references in nested <classpath>
> > attributes. Ant seems to refuse to accept classpaths like the following:
> >
> > <classpath>
> >    <pathelement path="${project.classpath}"/>
> > </classpath>
> >
> > In such a case, ant uses its own classpath (from executing
> > $ANT_HOME/bin/ant). If I add another element in the classpath such as:
> >
> > <classpath>
> >    <pathelement path="${project.classpath}"/>
> >    <pathelement location="./lib/core.jar" />
> > </classpath>
> >
> > Ant now only gives me a classpath with "./".
> >
> > in a case without references, it works fine:
> >
> > <classpath>
> >    <pathelement path="./classes"/>
> >    <pathelement location="./lib/core.jar" />
> > </classpath>
> >
> > Ant now only gives me a classpath with "./".
> >
> > I don't know if we can use the echo task to print out the content of
> > variables, so I wrote a simple Test class that prints out the classpath
> >
> (System.out.println("[java.class.path,"+System.getProperty("java.class.path")+"]");).
> > I haven't seen anyone with a similar problem in the mailing list except
> > maybe forked JVM's classpath not clean when using JUnit task. Since I
> > have no knowledge of JUnit, I'll assume fornow it's unrelated.
> >
> > ------------ ant execution script changes ----------------
> >
> > # SV 2001/11/08
> > export JAVA_HOME=/usr/java
> > export CLASSPATH=$ANTCLASSPATH
> >
> >
> > ------------- Code except --------------
> >
> > <project name="NADIM" default="all" basedir=".">
> >
> >  <!-- defines all of the homes -->
> >  <property file="build.properties" />
> >
> > ...
> >
> >  <path id="project.classpath">
> >    <path refid="jini.path" />
> >    <path refid="weblogic.path" />
> >    <fileset dir="${lib}">
> >      <include name="**/*.jar"/>
> >    </fileset>
> >  </path>
> >
> > ...
> >
> >  <target name="ejbmake">
> >    <!-- should be weblogic.ejbc20,
> >         Test only prints out the classpath
> >    -->
> >    <java classname="Test" fork="yes" >
> >       <sysproperty key="weblogic.home" value="${weblogic.home}"/>
> >       <arg value="-verbose"/>
> >       <arg value="${ejbtmp}"/>
> >       <arg value="${ejbjar}"/>
> >     <classpath>
> >     <pathelement path="${project.classpath}"/>
> >     </classpath>
> >   </target>
> >
> > ...
> > </project>
> >
> >
> > -------------- Environment ------------------
> > RedHat7.1
> > Ant 1.4.1
> > java version "1.3.1"
> > Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
> > Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
> >
> > Cheers,
> > Stephane Vaucher
> > Research Professional
> > CIRANO
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
> =====
> (holtdl@yahoo.com)
>
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: java task and classpath

Posted by Diane Holt <ho...@yahoo.com>.
The "${}" format is used to reference properties -- when referencing id's,
use the 'refid' attribute and just the name. Eg:
  <classpath>
    <path refid="project.classpath"/>
    <pathelement location="./lib/core.jar"/>
  </classpath>

To echo the value of the id'd path, you can set a property for it:
  <property name="project.classpath" refid="project.classpath"/>
  <echo message="project.classpath = ${project.classpath}"/>

Diane

--- stephane vaucher <va...@LUB.UMontreal.CA> wrote:
> Hello everyone,
> 
> I have a problem using the nested references in nested <classpath>
> attributes. Ant seems to refuse to accept classpaths like the following:
> 
> <classpath>
>    <pathelement path="${project.classpath}"/>
> </classpath>
> 
> In such a case, ant uses its own classpath (from executing
> $ANT_HOME/bin/ant). If I add another element in the classpath such as:
> 
> <classpath>
>    <pathelement path="${project.classpath}"/>
>    <pathelement location="./lib/core.jar" />
> </classpath>
> 
> Ant now only gives me a classpath with "./".
> 
> in a case without references, it works fine:
> 
> <classpath>
>    <pathelement path="./classes"/>
>    <pathelement location="./lib/core.jar" />
> </classpath>
> 
> Ant now only gives me a classpath with "./".
> 
> I don't know if we can use the echo task to print out the content of
> variables, so I wrote a simple Test class that prints out the classpath
>
(System.out.println("[java.class.path,"+System.getProperty("java.class.path")+"]");).
> I haven't seen anyone with a similar problem in the mailing list except
> maybe forked JVM's classpath not clean when using JUnit task. Since I
> have no knowledge of JUnit, I'll assume fornow it's unrelated.
> 
> ------------ ant execution script changes ----------------
> 
> # SV 2001/11/08
> export JAVA_HOME=/usr/java
> export CLASSPATH=$ANTCLASSPATH
> 
> 
> ------------- Code except --------------
> 
> <project name="NADIM" default="all" basedir=".">
> 
>  <!-- defines all of the homes -->
>  <property file="build.properties" />
> 
> ...
> 
>  <path id="project.classpath">
>    <path refid="jini.path" />
>    <path refid="weblogic.path" />
>    <fileset dir="${lib}">
>      <include name="**/*.jar"/>
>    </fileset>
>  </path>
> 
> ...
> 
>  <target name="ejbmake">
>    <!-- should be weblogic.ejbc20,
>         Test only prints out the classpath
>    -->
>    <java classname="Test" fork="yes" >
>       <sysproperty key="weblogic.home" value="${weblogic.home}"/>
>       <arg value="-verbose"/>
>       <arg value="${ejbtmp}"/>
>       <arg value="${ejbjar}"/>
>     <classpath>
>     <pathelement path="${project.classpath}"/>
>     </classpath>
>   </target>
> 
> ...
> </project>
> 
> 
> -------------- Environment ------------------
> RedHat7.1
> Ant 1.4.1
> java version "1.3.1"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
> Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
> 
> Cheers,
> Stephane Vaucher
> Research Professional
> CIRANO
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>