ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject RE: Parse jar:file prefix to Resource
Date Thu, 18 Dec 2014 18:11:26 GMT

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}">
            <path path="${java.class.path}"/>
            <name name="*.jar"/>
    </copy>looking inside a jar ...i think it might be best to leverage JarFileIterator

javap JarFileIterator.class produces:

public class implements
  public 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()

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

> Date: Wed, 17 Dec 2014 23:18:21 -0500
> Subject: Parse jar:file prefix to Resource
> From:
> To:
> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message