问题描述
我有一个复制任务集如下:
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?