【发布时间】:2018-01-23 09:55:39
【问题描述】:
我有一个复制任务集如下:
task copyToLib( type: Copy ) {
into "$buildDir/myapp/lib"
from configurations.runtime
// We only want jars files to go in lib folder
exclude "*.exe"
exclude "*.bat"
exclude "*.cmd"
exclude "*.dll"
// We exclude some lib
exclude group: "org.slf4j", name: "slf4j-api", version: "1.6.2"
}
我收到以下错误:
Could not find method exclude() for arguments [{group=org.slf4j, name=slf4j-api, version=1.6.2}] on task ':copyToLib' of type org.gradle.api.tasks.Copy
我觉得这只是一个语法问题,有什么提示吗?
【问题讨论】:
-
Copy 用于复制文件。所以你可以排除文件。你正在传递一张地图。以下是您可以使用的各种排除方法的文档:docs.gradle.org/current/dsl/…
-
非常感谢。因此,如果我理解得很好,以下应该可以解决问题: exclude {it.file in configurations.runtime.files {it.name.equals("slf4j-api")}} 。我不再收到任何错误,但仍包含资源...
-
没有。它应该看起来像
exclude "slf4j-api.jar"或exclude { it.file.name.contains('slf4j-api') }。运行时配置中没有名为 slf4j-api 的文件。 -
文件名可能是“slf4j-api-1.6.2.jar”
-
只有在按组排除或使用闭包时才应排除组。
标签: java gradle copy build.gradle