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"
     }
}
txtFiles = fileTree(dir: '.', include: '*.txt')

task zip1(type: Zip) {
    baseName = 'test3'
    from(txtFiles)
}

task zip2(type: Zip, dependsOn: 'zip1') {
    baseName = tasks['zip1'].baseName
    appendix = "upd"
    from(zipTree(tasks['zip1'].archivePath))
    from(txtFiles)
}

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to