Gradle exclude module for Copy task(复制任务的 Gradle 排除模块)
问题描述
我有一个复制任务集如下:
I have a Copy task set as follow:
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
我觉得这只是一个语法问题,有什么提示吗?
I have the feeling that it's only a syntax issue, any hint?
推荐答案
按组排除:排除组:org.slf4j
按模块排除:排除模块:slf4j-api
按文件名排除:exclude { it.file.name.contains('slf4j-api') }
排除文件:exclude "slf4j-api.jar"
您可以按组和模块排除,但需要像这样进入配置排除.然后它会在复制之前限制配置.
You can exclude by group and module but it needs to go into configurations exclude like this. Then it's gonna restrict the configuration before copying.
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
也许不是排除所有其他文件,而是只包含 jars?
And maybe instead of excluding all other files just include jars?
这篇关于复制任务的 Gradle 排除模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:复制任务的 Gradle 排除模块


基础教程推荐
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01