You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mark Harris <ma...@uk.easynet.net> on 2005/04/08 12:01:33 UTC

Classpath reference

Hello,

Apache Ant version 1.6.2

I have a problem with my Ant script. I create a classpath reference at
the start of the script, like this:

    <path id="classpath">
        <pathelement location="/myjar.jar"/>
        <pathelement location="/myotherjar.jar"/>
        <pathelement location="/my3rdjar.jar"/>
    </path>

... but when I reference this from one of the targets in the build
script (a JUnit test), it doesn't seem to be picking up the elements
in the reference.

I define the classpath in the target as below. I need to add
additional jars into the classpath at this point, so I use
<pathelement location=""/> to do this.

    <target name="test">
        <junit printsummary="no">
            <classpath>
                <pathelement path="${classpath}"/>
                <pathelement location="/myadditionaljar.jar"/>
            </classpath>
... etc...

When I try and run the target from the script, I get lots of
java.lang.NoClassDefFoundError exceptions - the classes which should
be included in the <classpath> reference. I'm sure that the line in
error is <pathelement path="${classpath}"/> (if I replace the
<pathelement path="${classpath}"/> line with a repeat of the
<pathelement location=""/> lines for the jars I defined at the top
of my script, it works without a problem), but I can't work out
why. I couldn't find any obvious solution in the online manual.

Thanks for any assistance,

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Classpath reference

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Mark,

try this :

     <target name="test">
         <junit printsummary="no">
             <classpath>
+                  <path refid="classpath"/>
-                 <pathelement path="${classpath}"/>
                 <pathelement location="/myadditionaljar.jar"/>
             </classpath>

Cheers, 

Antoine

> Hello,
> 
> Apache Ant version 1.6.2
> 
> I have a problem with my Ant script. I create a classpath reference at
> the start of the script, like this:
> 
>     <path id="classpath">
>         <pathelement location="/myjar.jar"/>
>         <pathelement location="/myotherjar.jar"/>
>         <pathelement location="/my3rdjar.jar"/>
>     </path>
> 
> ... but when I reference this from one of the targets in the build
> script (a JUnit test), it doesn't seem to be picking up the elements
> in the reference.
> 
> I define the classpath in the target as below. I need to add
> additional jars into the classpath at this point, so I use
> <pathelement location=""/> to do this.
> 
>     <target name="test">
>         <junit printsummary="no">
>             <classpath>
>                 <pathelement path="${classpath}"/>
>                 <pathelement location="/myadditionaljar.jar"/>
>             </classpath>
> ... etc...
> 
> When I try and run the target from the script, I get lots of
> java.lang.NoClassDefFoundError exceptions - the classes which should
> be included in the <classpath> reference. I'm sure that the line in
> error is <pathelement path="${classpath}"/> (if I replace the
> <pathelement path="${classpath}"/> line with a repeat of the
> <pathelement location=""/> lines for the jars I defined at the top
> of my script, it works without a problem), but I can't work out
> why. I couldn't find any obvious solution in the online manual.
> 
> Thanks for any assistance,
> 
> Mark
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org