用于复制任务的Gradle排除模块 [英] Gradle exclude module for Copy task

查看:707
本文介绍了用于复制任务的Gradle排除模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 任务copyToLib(类型:复制){
到 $ buildDir / myapp / lib
from configurations.runtime

//我们只希望jars文件进入lib文件夹
排除* .exe
排除* .bat
排除* .cmd
排除* .dll

//我们排除某些lib
exclude组:org.slf4j ,name:slf4j-api,version:1.6.2
}

我得到以下错误:

 无法为参数找到方法exclude()[{group = org.slf4j ,org.gradle.api.tasks.Copy 

$任务':copyToLib',name = slf4j-api,version = 1.6.2} b
$ b

我觉得这只是一个语法问题,任何提示?

解决方案

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



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



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



排除一个文件:排除slf4j-api.jar



您可以按组和模块排除,但它需要进入配置排除这样。然后它会限制复制前配置。

 任务copyToLib类型:复制){
到配置中的$ buildDir / myapp / lib
。运行{
排除组:'org.slf4j'
}

//我们只想把jars文件放到lib文件夹中
排除* .exe
排除* .bat
排除* .cmd
排除 * .dll

}

请记住确保目录是否存在 $ buildDir / myapp / lib



也许不是排除所有其他文件,而只包括jar吗?


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"
}

And i'm getting the following error:

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?

解决方案

Exclude by group: exclude group: org.slf4j

Exclude by module: exclude module: slf4j-api

Exclude by file name: exclude { it.file.name.contains('slf4j-api') }

Exclude a file: 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"

}

And remember to make sure that the directory exists $buildDir/myapp/lib

And maybe instead of excluding all other files just include jars?

这篇关于用于复制任务的Gradle排除模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆