我有一個副本任務設置如下:搖籃排除模塊複製任務
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
我有,這只是一個語法的感覺問題,任何提示?
複製用於複製文件。所以你可以排除文件。您正在傳遞地圖。以下是您可以使用的各種排除方法的文檔:https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:排除(groovy.lang.Closure) –
很感謝。所以,如果我理解得很好,下面應該做的伎倆:排除{it.file in configurations.runtime.files {it.name.equals(「slf4j-api」)}}。我再也沒有收到任何錯誤,但資源仍然包含在內...... – hublo
不,它應該看起來像'exclude「slf4j-api.jar」',或'exclude {it.file.name.contains('slf4j -api')}'。運行時配置中沒有名爲slf4j-api的文件。 –