Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
<whichresource > Diff + Testcase

<whichresource > Diff + Testcase

2004-01-11       - By Jack J. Woehr
Reply:     1     2  

koji_sekiguchi@(protected) 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@(protected)
> For additional commands, e-mail: user-help@(protected)

--
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@(protected)
For additional commands, e-mail: user-help@(protected)



©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.