Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to create a Zip archive in Gradle

Tags:

gradle

zip

I'm trying to create a simple Zip archive that contains all the javascript files in my resources directory

Here's the code:

  task zip(type:Zip){
    from ('resources/'){
        include '*.js'
    }
    into 'resources'
}

This does not seem to work for some reason. I've heard many people saying that all you need is a from and into to create an archive. Can someone help me here ? I'm using Gradle v1.0. Thanks in advance.

like image 704
Kiran Avatar asked Jul 15 '12 20:07

Kiran


2 Answers

Try something like this (docs):

task zip(type:Zip) {
 from ('resources/')
 include '*.js'
 into 'resources' // note that this specifies path *in* the archive
 destinationDir file('dir') // directory that you want your archive to be placed in
}
like image 59
Artur Nowak Avatar answered Oct 21 '22 13:10

Artur Nowak


task someTask << {

    // other code...

    task(zipResources, type: Zip) {
        destinationDir new File(projectDir, 'resources')
        archiveName 'resources.zip'
        from 'src/main/webapp'
        include '*.js'
    }.execute()

    task(zipSomethingElse, type: Zip) {
        destinationDir buildDir
        archiveName 'source-code.zip'
        from 'src/main/java'
        include '**/*.java'
    }.execute()

    // some other code...

}
like image 22
Maxim Butov Avatar answered Oct 21 '22 11:10

Maxim Butov