按组排除: exclude group: org.slf4j
按模块排除: exclude module: slf4j-api
按文件名排除: exclude { it.file.name.contains('slf4j-api') }
排除文件: exclude "slf4j-api.jar"
然后它将限制复制之前的配置。
task copyToLib( type: Copy ) {
into "$buildDir/myapp/lib"
from configurations.runtime {
exclude group: 'org.slf4j'
}
// We only want jars files to go in lib folder
exclude "*.exe"
exclude "*.bat"
exclude "*.cmd"
exclude "*.dll"
}
并记住确保该目录存在 $buildDir/myapp/lib