You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ma...@cs.tcd.ie on 2003/05/16 17:08:11 UTC

Jar list

Hi folks,
          Is there any ant task available that will print out the
contents of a jar file and then in turn have this executed for all the
jars in a folder? 
I've looked at the jar and unjar tasks but they're not exactly what I
had in mind. 
 
Thanks,
Mark.
 
 

Re: Jar list

Posted by Mark Crocker <mc...@markcrocker.com>.
On Fri, 16 May 2003 16:08:11 +0100, Mark.Gargan@cs.tcd.ie wrote:

>           Is there any ant task available that will print out the
> contents of a jar file and then in turn have this executed for all the
> jars in a folder?
> I've looked at the jar and unjar tasks but they're not exactly what I
> had in mind.

Yes there is, but I haven't submitted it yet.

I was just putting the finishing touches on the documentation for a version of the unjar, untar, unwar and unzip tasks (really org.apache.tools.ant.taskdefs.Expand) when I discovered that my starting source was out of sync with the CVS and someone had made a change to Expand.java that wasn't in version that I started with (oops!).  So, I have to port my changes over to a new version before I can look into the procedure for submitting my changes to the apache-ant developers.  I also have to finish up my test case changes too.  I hope to have something available for submission in the next day or two.

My updated Expand simply adds a Mapper to the task.  This allows you do something like this:

	<unjar dest="${dir.preverified}">
	  <fileset dir="${dir.src}">
	    <include name="*.jar" />
	    <include name="*.zip" />
	  </fileset>
	  <mapper type="regexp" from="^(.*)\.(jar|zip)$$" to="\1/" />
	</unjar>

	This unpacks all files ending in .jar or .zip in the source directory and puts the contents of each into a subdirectory of the preverified directory with the same name as the original archive file without the trailing .jar or .zip. For example, the contents of src/purifier.zip and src/ant.jar will be extracted to preverified/purifier/ and preverified/ant/ directories respectively.

	When ${dir.src} = /Users/mcrocker/dev/Projects/Java/Purifier/src/TestCases/proprietary/midlet.org
	and ${dir.preverified} = /Users/mcrocker/dev/Projects/Java/Purifier/TestCases/preverified/proprietary/midlet.org
	A snipped of the log output looks like:

		[unjar] Expanding: /Users/mcrocker/dev/Projects/Java/Purifier/src/TestCases/proprietary/midlet.org/Websters.jar into /Users/mcrocker/dev/Projects/Java/Purifier/TestCases/preverified/proprietary/midlet.org/Websters
		[unjar] Expanding: /Users/mcrocker/dev/Projects/Java/Purifier/src/TestCases/proprietary/midlet.org/WorldTime.jar into /Users/mcrocker/dev/Projects/Java/Purifier/TestCases/preverified/proprietary/midlet.org/WorldTime
		[unjar] Expanding: /Users/mcrocker/dev/Projects/Java/Purifier/src/TestCases/proprietary/midlet.org/WorldWeather.jar into /Users/mcrocker/dev/Projects/Java/Purifier/TestCases/preverified/proprietary/midlet.org/WorldWeather

If you need this functionality right away, I can send you an advanced copy, but I recommend you wait until I submit a new version.

For those who are curious, this is being used for the Purifier project, which is a pure Java J2ME preverifier (see http://www.markcrocker.com/~mcrocker/Computer/Purifier/).  As a part of the test process, StackMaps from existing Midlets are compared against those created by the Purifier.  The Midlets need to be extracted, while keeping the namespaces intact and avoiding collisions for this to work.  Collision avoidance is impossible with the existing unjar task for several reasons including the fact that so many of the Midlets are obfuscated and have class names of a.class, b.class, c.class etc...

           __    
     __   / /\   
    /  /\/ / /_  ------------------------------------
   /  /  \/ / /\ Mark Crocker                        
  /  / /\ \ \/ / mcrocker@markcrocker.com            
 /  /  \_\/\  /  http://www.markcrocker.com/~mcrocker
/__/ /\ \ \_\/   ------------------------------------
\  \ \_\/        
 \  \ \          
  \__\/