You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Jack J. Woehr" <ja...@purematrix.com> on 2004/01/11 19:03:31 UTC
Re: Diff + Testcase
koji_sekiguchi@excite.co.jp wrote:
> How do you write build.xml to get the URL for
> org.apache.tools.ant.Main.class? Does it actually work?
Here's a testcase which proves Mr. Sekiguchi's point.
------------------------------------
<project name="test-whichresource" default="dotest">
<target name="dotest">
<whichresource property="testresult" class="org.apache.tools.ant.Main"/>
<echo message="${testresult}"/>
</target>
</project>
-------------------------------------
In Ant 1.7 alpha the output is:
dotest:
[echo] ${testresult}
With the diff suggested the output is:
dotest:
[echo] jar:file:/usr/local/ant/lib/ant.jar!/org/apache/tools/ant/Main.class
Here again is the diff:
Index: src/main/org/apache/tools/ant/taskdefs/WhichResource.java
===================================================================
RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/WhichResource.java,v
retrieving revision 1.6
diff -c -r1.6 WhichResource.java
*** src/main/org/apache/tools/ant/taskdefs/WhichResource.java 12 Dec 2003 19:32:58 -0000 1.6
--- src/main/org/apache/tools/ant/taskdefs/WhichResource.java 11 Jan 2004 17:53:11 -0000
***************
*** 169,175 ****
if (classname != null) {
//convert a class name into a resource
classname = classname.replace('.', '/');
! resource = "/" + classname + ".class";
} else {
if (!resource.startsWith("/")) {
resource = "/" + resource;
--- 169,175 ----
if (classname != null) {
//convert a class name into a resource
classname = classname.replace('.', '/');
! resource = /* "/" + */ classname + ".class";
} else {
if (!resource.startsWith("/")) {
resource = "/" + resource;
In Ant 1.7 alpha without the diff I previously
posted, the output is
>
>
> In ant.jar, the class is like this:
> org/apache/tools/ant/Main.class
>
> But WhichResource.java look for
> "/org/apache/tools/ant/Main.class", so
> it cannot always get the URL regardless classpath.
>
> regards,
>
> Koji
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
--
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