ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject <whichresource>
Date Sun, 11 Jan 2004 02:56:18 GMT

I try to use <whichresource> task. To get a url for an ant class,
I run the following code:

    <whichresource class="" property="which"/>

On the screen, it seems that Ant added "/" at the front of the class
and looked for it:

[whichresource] Searching for /org/apache/tools/ant/Main.class

As a result, Ant couldn't find it. Then I provided another ant.jar which
was created by using <jar> task with <zipfileset src="ant.jar" prefix="/"/>

    <jar destfile="another/ant.jar">
	<zipfileset prefix="/" src="ant.jar"/>

>From this, I got another ant.jar which has entries with prefix "/" like this:

$ jar tf ant.jar | grep Main

Then, using <whichresource> task with this ant.jar in the search classpath,
now I can find the class successfully.

The following is a code snippet from

        if (classname != null) {
            //convert a class name into a resource
            classname = classname.replace('.', '/');
            resource = "/" + classname + ".class";
        } else {
            if (!resource.startsWith("/")) {
                resource = "/" + resource;

I think '"/" + ' may be removed...

Thank you,


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

View raw message