You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Yves Martin <yv...@elca.ch> on 2005/01/07 12:21:50 UTC
Proposal: improve 'whichresource' features
Hello,
Maybe I have not understood well what is the aim of 'whichresource' and how to
use it - but here is my problem:
To get the simple jar file name that contains a class loaded from the Ant lib/
directory, I had to do:
<whichresource
class="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"
property="ant-junit.url"/>
<pathconvert property="ant-junit-jarfile" pathSep="?">
<path location="${ant-junit.url}"/>
<mapper type="glob"
from="${basedir}${file.separator}jar:file:*!/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class"
to="*"/>
</pathconvert>
It is only working on Linux...
On Windows, ant-junit-jarfile is empty.
The value of 'ant-junit.url' on Windows is
jar:file:/C:/Program%20Files/Ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class
[ The URI RFC says the ':' is a reserved character BUT it is used to express
the ugly windows drive notation... Another issue for me. Does the JDK
provide valid file: URL on Windows ? ]
Is there a portable way to get that code working ?
Isn't it simpler to add an output option to 'whichresource' ?
<whichresource
class="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"
property="ant-junit.url"
output="file"/>
The "output" values may be
- 'url': complete URL,
- 'jar': if protocol is jar, only the part between "jar:" and "!"
- 'file': if protocol is file, only the file name)
and so on.
So whichresource will only write in the property the part on the URL we are
interested in. URL specification is not enough: it has to understand some
protocols to be able to remove "!..." part in case of "jar:" protocol for
instance.
What do you think about that idea ? I'm ready to work on it if ok. Or else I
will have to create my own task.
Thank you in advance for your answers
--
Yves Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org