Dependencies gradle压缩依赖项的一部分,命名文件树

Dependencies gradle压缩依赖项的一部分,命名文件树,dependencies,zip,gradle,Dependencies,Zip,Gradle,我在尝试创建包含项目依赖项的zip存档时遇到了一些问题。 我有以下依赖结构: dependencies { compile 'org.codehaus.groovy:groovy-all:2.1.7' compile fileTree(dir: 'libs/', include: '*.jar') // I want this to be packed compile fileTree(dir: 'do_not_need_in_zip', include: '*.jar'

我在尝试创建包含项目依赖项的zip存档时遇到了一些问题。 我有以下依赖结构:

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.1.7'
    compile fileTree(dir: 'libs/', include: '*.jar') // I want this to be packed
    compile fileTree(dir: 'do_not_need_in_zip', include: '*.jar') // This must be excluded.
}
我试图只将前两个依赖项打包到归档中。但无法设法过滤它们。我正试着这样做

task dist(type: Zip, dependsOn ...) {
    from (project.configurations.compile.files { dep ->
    dep.name == 'groovy-all'
})
into 'lib'
}
但是对于
fileTree
依赖项名称是未指定的,因此,我无法筛选这种依赖项

也许,我需要在变量中保存依赖项,也许是smth。其他的你能给我一个建议吗

编辑: 此时,我有一系列依赖项要添加到存档中,如下所示。这是肮脏的,但我认为,工作的解决方案

dependencies {
    distributionFiles.each{
        compile it
}   }

但是@Rene的答案在我看来更清楚。

一种方法是拆分您正在使用的配置。e、 g.创建提供的编译配置,并将zip中不需要的DEP分配给该提供的编译配置