Hey Olivier the last time I looked the Java zip code could not update a zip, so I think that's the limitation. If your input is an existing zip on one file you want to change you need to unzip update rezip and overwrite.
- Peace Dave On Mon, Jul 11, 2011 at 6:59 PM, Olivier Lefevre <[email protected]> wrote: > Peter, using this method you end up with two copies of the updated files > inside the jar if they were already there, which is not how "jar u" is > supposed to work! I didn't know that was possible but that is clearly > never a desirable thing. I have attached a script that demonstrates this > behaviour, create one or more *.txt files in the root directory, run the > zip2 task and do 'unzip -l test3-upd.zip'. A similar test for jar tasks > would yield similar results. > > Moreover it seems that "from zipTree" expands the archive in a temp dir, > which is wasteful (AFAIK neither jar nor zip do that when updating a file). > > So, is there any way to perform a zip/jar update *correctly* (i.e., without > creating duplicates) and in-place (i.e., without temporary expansion) > using the Gradle DSL? > > On 3/3/2011 3:18 PM, Peter Niederwieser wrote: >> >> richardm wrote: >>> >>> However, my questions still stands, can you update a JAR using the Gradle >>> DSL, or is using the Ant task the only way? >>> >> >> Gradle's file handling capabilities make this kind of task easy. For >> example, to add file "some_file.txt" to the META-INF directory of the >> original Jar: >> >> task enrichedJar(type: Jar, dependsOn: "jar") { >> appendix = "enriched" >> from zipTree(jar.archivePath) // add original content >> from(file("some_file.txt")) { // add new content >> into "META-INF" >> } >> } > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
