Java Mailing List Archive

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

Apache Ant Archive

» Ant Users List
» Ant Developers List
<whichresource > DIFF attached, Should Solve It

<whichresource > DIFF attached, Should Solve It

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

koji_sekiguchi@(protected) wrote:

> Can you look for the above properties file from ant.jar
> by using <whichresource> task?
> It seems same bug for me..
> I think "adding leading slash" is ant user's option.

Ok, I *THINK* I have it all solved and figured out:

 1. A class in a jar can't have the leading slash.
 2. A resource in a jar can't have the leading slash.

So, here is a diff that removes both leading slash concatenations, along with a
test
case that succeeds all ways. The test case:

 1. Finds a class from the file system
 2. Finds a class from a jar
 3. Finds a resource from the file system
 4. Finds a resource from a jar

Its output is:

    dotest:
         [echo] Class search in filesystem yields: file:/usr/local/src/apache
/apache_src/ant-antidote/build/classes/org/apache/tools/ant/gui/Antidote.class
         [echo] Class search in jar yields: jar:file:/usr/local/src/apache
/apache_src/ant-antidote/build/lib/antidote.jar!/org/apache/tools/ant/gui
/Antidote.class
         [echo] Resource search in filesystem yields: file:/usr/local/src
/apache/apache_src/ant-antidote/build/classes/org/apache/tools/ant/gui/resources
/About.gif
         [echo] Resource search in jar yields: jar:file:/usr/local/src/apache
/apache_src/ant-antidote/build/lib/antidote.jar!/org/apache/tools/ant/gui
/resources/About.gif

Here's the test case:


    <?xml version="1.0" standalone="yes"?>

    <project name="test-whichresource" default="dotest">
        <target name="dotest">

      <whichresource property="testresult.antidote.class.filesystem"
     class="org.apache.tools.ant.gui.Antidote" classpath="/usr/local/src
/apache/apache_src/ant-antidote/build/classes"/>
     <echo message="Class search in filesystem yields: ${testresult.antidote
.class.filesystem}"/>

     <whichresource property="testresult.antidote.class.jar"
     class="org.apache.tools.ant.gui.Antidote" classpath="/usr/local/src
/apache/apache_src/ant-antidote/build/lib/antidote.jar"/>
     <echo message="Class search in jar yields: ${testresult.antidote.class
.jar}"/>

      <whichresource property="testresult.antidote.resource.filesystem"
     resource="org/apache/tools/ant/gui/resources/About.gif" classpath="/usr
/local/src/apache/apache_src/ant-antidote/build/classes"/>
     <echo message="Resource search in filesystem yields: ${testresult
.antidote.resource.filesystem}"/>

     <whichresource property="testresult.antidote.resource.jar"
     resource="org/apache/tools/ant/gui/resources/About.gif" classpath="/usr
/local/src/apache/apache_src/ant-antidote/build/lib/antidote.jar"/>
     <echo message="Resource search in jar yields: ${testresult.antidote
.resource.jar}"/>

        </target>

    </project>

The diff that makes this work is attached.

NOW have we got it right? :-)

--
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.