I have this structure in a zip file
classes
|--com: A.class, B.class
|--org: C.class, D.class
|--android: X.class
|--stuff: Stuff.inf, info.txt
I want be able to extract only the folders with .class files: com, org, android. And put them on a jar.
So far I have done this:
task createJar {
//unzip the file
FileTree zip = zipTree('runtime.jar')
FileTree zip2 = zip.matching {
include 'classes/**/*.class'
}
zip2.each { file -> println "doing something with $file" }
//create the jar
jar{
from zip2
destinationDir file('GradleTests/testResult')
}
}
But I get the jar with the classes folder on it, like: classes/org/apache/http/entity/mime/content/StringBody.class
And i want it like: org/apache/http/entity/mime/content/StringBody.class
Any idea how?
Thanks!
So I think there are two main things that can get you closer to what you want:
zipTreedirectly in thejartask rather than creating an intermediate zip.eachFileto change the relative path of each file to strip off the first folder.Jar tasks have all of the CopySpec methods, which provide the eachFile abilities.