14

我正在尝试创建一个简单的 Zip 存档,其中包含我的资源目录中的所有 javascript 文件

这是代码:

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

由于某种原因,这似乎不起作用。我听过很多人说你只需要一个frominto创建一个档案。有人可以在这里帮助我吗?我正在使用 Gradle v1.0。提前致谢。

4

2 回答 2

22

尝试这样的事情(文档):

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
}
于 2012-07-15T20:29:45.427 回答
10
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...

}
于 2013-06-28T11:49:59.247 回答