You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ko...@excite.co.jp on 2004/01/11 03:56:18 UTC
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
Re:
Posted by "Jack J. Woehr" <ja...@purematrix.com>.
koji_sekiguchi@excite.co.jp wrote:
> 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:
You should probably use the classpath attribute of the whichresource task.
--
Jack J. Woehr # We have gone from the horse and buggy
Senior Consultant # to the moon rocket in one lifetime, but
Purematrix, Inc. # there has not been a corresponding moral
www.purematrix.com # growth in mankind. - Dwight D. Eisenhower
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org