如何在Gradle中复制一些依赖项jar

如何在Gradle中复制一些依赖项jar,gradle,Gradle,假设我在Gradle有这种依赖性: providedCompile( 'javax:javaee-api:7.0', 'org.slf4j:slf4j-api:1.7.21', 'com.fasterxml.jackson.core:jackson-databind:2.5.4', 'com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.5.4',

假设我在Gradle有这种依赖性:

   providedCompile(
        'javax:javaee-api:7.0',
        'org.slf4j:slf4j-api:1.7.21',
        'com.fasterxml.jackson.core:jackson-databind:2.5.4',
        'com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.5.4',
        'net.sf.ehcache:ehcache:2.10.3',
        'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.4',
 )
(我使用从war插件提供的编译作为ai)

我有编译时的JAR,但在构建完所有内容后,我需要将其中一些(不是全部)依赖项中使用的JAR复制到几个目录中,以将它们配置为Liberty服务器中的库,然后用它创建一个Docker。例如,我需要排除ehcache jar,因为它们是应用服务器中持久性引擎的一部分

我试过:

task copyRuntimeLibs(type: Copy) {
    from (configurations. providedCompile - 'net.sf.ehcache:ehcache:2.10.3')
    into "build/docker/dependenciesLibrary"
}
但这行不通。ehcache中的jar仍被复制

我如何在Gradle中创建一个复制任务,从例如那些jackson依赖项(但不复制JavaEEAPI依赖项)获取JAR

谢谢你可以试试

task copyRuntimeLibs(type: Copy) {
    from (configurations.providedCompile){
        exclude 'ehcache-2.10.3.jar'
    }
    into "build/docker/dependenciesLibrary"
 }
而且

task copyRuntimeLibs(type: Copy) {
    from (configurations.providedCompile){
        exclude 'ehcache*.jar'
    }
    into "build/docker/dependenciesLibrary"
}
两种方法都很好

但实际上我不知道是否有一种方法可以直接使用'net.sf.ehcache:ehcache:2.10.3'而不是使用'ehcache-2.10.3.jar'排除'ehcache*.jar'