ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From koji_sekigu...@excite.co.jp
Subject <whichresource>
Date Sun, 11 Jan 2004 02:56:18 GMT
Hello,

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

    <whichresource class="org.apache.tools.ant.Main" 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="/"/>
type:

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

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

$ jar tf ant.jar | grep Main
/org/apache/tools/ant/Main.class
/org/apache/tools/ant/helper/ProjectHelper2$MainHandler.class

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 WhichResource.java:

        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,

Koji

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


Mime
View raw message