Matt

At the Directory Level: You can grab all the filtered jars you need with 
<archives> and <zips> and <restrict> tags e.g.
    <copy todir="${target}">
      <archives>
        <zips>
          <restrict>
            <path path="${java.class.path}"/>
            <name name="*.jar"/>
          </restrict>
        </zips>
      </archives>
    </copy>looking inside a jar ...i think it might be best to leverage 
JarFileIterator

javap JarFileIterator.class produces:

public class org.apache.tools.ant.taskdefs.optional.depend.JarFileIterator 
implements org.apache.tools.ant.taskdefs.optional.depend.ClassFileIterator {
 public 
org.apache.tools.ant.taskdefs.optional.depend.JarFileIterator(java.io.InputStream)
 throws java.io.IOException;
  public org.apache.tools.ant.taskdefs.optional.depend.ClassFile 
getNextClassFile();
}

so as you can see if you already have one file and get an InputStream you can 
pass InputStream to JarFileIterator(InputStream)
then setup an iterator and continously get the next Class File using ClassFile 
getNextClassFile() method

this is clumsy and assumes you have a InputStream ready to go the alternate 
strategy might be to grab the source:
put test input jar in a "known location" e.g. /temp folder
modify the source constructor so that ctor will always read the jar file 
located in /temp (instead of InputStream)
create some sort of exportable Collection (ArrayList?)
toss in a while loop which reads the Jar file contents and populates a public 
static ArrayList
in the end reference the ArrayList that was exported... to get the list of 
Class Files

Does anyone have  any ideas to help Matt?

Buona Fortuna
Martin 
______________________________________________ 



> Date: Wed, 17 Dec 2014 23:18:21 -0500
> Subject: Parse jar:file prefix to Resource
> From: viper2...@gmail.com
> To: user@ant.apache.org
> 
> Hi,
> 
> I am writing some custom ant tasks and I want to support files inside of
> zip/jar files. I have noticed that some ant tasks use the
> jar:file:/path/to/a.jar!/path/in/jar/file.xml syntax but I can't seem to
> get it work. How do I use this pattern in my tasks and map them to a
> Resource object like FileResource, URLResource, etc. Thanks.
> 
> Matt Bertolini
                                          

Reply via email to