For a mystery project, I preferred to take jars from a few upstream java projects and combine them into a single jar for convenient distribution. Following hints on the Gradle Wiki, I created a fourth java project and create a trivial build.gradle consisting essentially of this:
jar {
project.rootProject.subprojects.each( {aproject ->
if ( project != aproject ) { // avoid recursion
aproject.tasks.withType(Jar).each
}
}
}
This almost works. It does not work in that the resulting jar has 3 or 4 manifests and multiple entries for some directories. Zip allows entries with duplicate names, little did I know.
I suspect this is just an unintended consquence of the recent refactoring of Archive tasks. In any case, I expect, at a minimum, that there would be an easy setting to make "from zipTree" act more like the old Jar merge method. (I couldn't find anything promising in 30 minutes of api/code browsing.) What I really expect is that this would be the default behavior; it must be the 99% case for adding files to jars.
Thanks for your consideration!
- Duplicated by
-
GRADLE-2171 Add an option to avoid duplicate entries when creating a zip file
- Resolved
- Related to
-
GRADLE-2177 When a subproject classesDir have been altered, if the subproject is used as a dependency the new output location is not used in the compile classpath
- Resolved