icordoba
icordoba

Reputation: 1899

How to copy dependency jars in a gradle task to a directory, fully deleting all files of old one

For my integration test automation with Gradle I need to copy the library directory into the directory where my Dockerfile resides to generate the docker image. I am doing this:

task copyRuntimeLibsToLocal(type: Copy) {
    group = 'docker'
    dependsOn   'build'
    from (configurations.compileOnly){
        exclude 'ehcache*.jar'
    }
    into "/MYDOCKERDIR/dependenciesLibraryDir"
}

But how can I make sure that old jars in dependenciesLibrary are deleted?

Upvotes: 1

Views: 516

Answers (1)

Vampire
Vampire

Reputation: 38734

Use type: Sync instead of type: Copy. They are the same except that Sync additionally removes files that are present in the destination directory and are not copied.

Upvotes: 4

Related Questions