gpt4 book ai didi

java - 用于复制任务的 Gradle 排除模块

转载 作者:行者123 更新时间:2023-12-02 13:50:34 25 4
gpt4 key购买 nike

我的复制任务设置如下:

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

我感觉这只是一个语法问题,有什么提示吗?

最佳答案

按组排除:排除组:org.slf4j

按模块排除:排除模块:slf4j-api

按文件名排除:exclude { it.file.name.contains('slf4j-api') }

排除文件:排除“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

也许不是排除所有其他文件而只是包含 jars?

关于java - 用于复制任务的 Gradle 排除模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45693516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com