Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Zip task to do multiple sub-trees?

Tags:

java

gradle

zip

We're trying to build up a minorly complicated Zip file in Gradle from multiple filesystem source trees, but no matter how many into specifications we give, it all puts them in the same one. Is this possible to do in Gradle?

build/libs/foo.jar --> foo.jar
bar/*              --> bar/*

We're getting this instead:

build/libs/foo.jar --> bar/foo.jar
bar/*              --> bar/*

Using this:

task installZip(type: Zip, dependsOn: jar) {
    from('build/libs/foo.jar').into('.')
    from('bar').into('bar')
}

Any help would be appreciated.

EDIT: Gradle 1.0-milestone-3

like image 485
Alan Krueger Avatar asked May 16 '11 19:05

Alan Krueger


1 Answers

Apparently the comments to an answer will not allow for a convenient way to show more code... or it isn't obvious :) I have a project which is for a client... so I can't share the full project / build file. Here is what I can share (I changed the project specific acron to XXX):

task zip(type: Zip) {

    from jar.outputs.files

    from('scripts/') {
        fileMode = 0755
        include '**/runXXX.sh'
        include '**/runXXX.bat'
    }
    from('lib/') {
        include '**/*.jar'
        into('lib')
    }
    from('.') {
        include 'xxx.config'
    }

}

This creates a zip with the project jar in the root of the zip. Copies the scripts from a directory to the root, copies the config file to the root and creates a directory in the root of the zip named /lib and copies all the jars from the project /lib to the zip/lib.

like image 137
kensipe Avatar answered Nov 03 '22 05:11

kensipe