ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yves Martin <>
Subject Re: How to get the jar file of a resource ?
Date Fri, 07 Jan 2005 10:37:35 GMT
Stefan Bodewig <> writes:

> On Fri, 17 Dec 2004, Yves Martin <> wrote:
>>  My idea is too limit the ClassPath to the strict needed jars - so I
>>  do not want to use ${java.class.path} in the forked JVM ClassPath.
> <junit> has an includenantruntime that you could set to false.
>>  Of course it does not work because 
>>   ant-junit.url ==
>>   /my/path/to/apache-ant-1.6.2/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class
>>  How can I get only the resource file
>>  /my/path/to/apache-ant-1.6.2/lib/ant-junit.jar to use it in
>>  ClassPath ?
> The usually recommended string manipulating task is pathconvert,
> something like
> <pathconvert property="jarfile" ...>
>   <path location="${ant-junit.url}"/>
>   <mapper type="glob"
>           from="*!/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class"
>           to="*"/>
> </pathconvert>
> would probably work.


 I'm using JDK 1.4 and I thought it works for the only reason I'm running on
 Linux. In debug mode, I understood why:

Resource org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class loaded from ant
Setting project property: ant-junit.url -> jar:file:/mypath/apache-ant-1.6.2/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class
[pathconvert] Set property ant-junit-jarfile = /mypath/jar:file:/mypath/apache-ant-1.6.2/lib/ant-junit.jar
Setting project property: ant-junit-jarfile -> /mypath/jar:file:/mypath/apache-ant-1.6.2/lib/ant-junit.jar

 So my 'ant-junit-jarfile' in a Unix ClassPath is OK (dirty but it works). On
 Windows, it simply failed.

 I tried the following mapper

 But as far as my original path contains ':', it is splitted and the mapper
 matches nothing - so the result is empty !

 <pathconvert property="ant-junit-jarfile" pathSep="?">
   <path path="${ant-junit.url}"/>
   <mapper type="glob"

 Have you got a way to work-around that issue with Windows ?

 Thank you in advance for your help
Yves Martin

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message