icordoba
icordoba

Reputation: 1899

How to copy some of the dependencies jars in Gradle

Let's say I have this dependency in 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',
 )

(I use providedCompile from war plugin as ai)

I have that for compile time but after everything is built, I need to copy the jars used in some (not all) of those dependencies to a couple of directories to configure them as Libraries in my Liberty Server, after that I create a Docker with that. For example I need to exclude ehcache jars as they are parte of the persistence engine in the app server.

I have tried:

task copyRuntimeLibs(type: Copy) {
    from (configurations. providedCompile - 'net.sf.ehcache:ehcache:2.10.3')
    into "build/docker/dependenciesLibrary"
}

but it won't work. Jars from ehcache are still copied.

How can I create a copy task in Gradle that gets jars from, for example, those jackson dependencies (but not copying javaee-api ones)

thanks

Upvotes: 2

Views: 1512

Answers (1)

mibrahim.iti
mibrahim.iti

Reputation: 2060

You can try

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

and also

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

and both will work fine,

But actually i don't know if there are a way to use 'net.sf.ehcache:ehcache:2.10.3' direct instead of using 'ehcache-2.10.3.jar' or exclude 'ehcache*.jar'

Upvotes: 3

Related Questions