I have a multi-module project. Only a single module produces the executable jar that need to run the code. I am using the application plugin with allows me to generate a zip file but I noticed the zip files contains many transitive dependencies from different version of the jar files. I want to exclude those files different versions of the jar.
I have tried to add
configurations.all {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
eachDependency { DependencyResolveDetails details ->
if (details.requested.group + ":" + details.requested.name == 'io.dropwizard.metrics:metrics-core') {
details.useVersion "3.1.2"
//details.useTarget "com.google.guava:guava:15.0:cdi1.0"
}
}
// cache dynamic versions for 10 minutes
cacheDynamicVersionsFor 10*60, 'seconds'
// don't cache changing modules at all
cacheChangingModulesFor 0, 'seconds'
}
}
and
applicationDistribution.with {
exclude '**/junit-4*.jar'
exclude '**/hamcrest-core-1*.jar'
exclude '**/commons-collections-3*.jar'
exclude '**/commons-lang-2*.jar'
exclude '**/jersey-apache-client-1*.jar'
exclude '**/jetty-util-6.*.jar'
exclude '**/metrics-core-2*.jar'
}
but the resulting jar still have those files when I list it.
metrics-core-2.2.0.jar
metrics-core-3.0.2.jar
metrics-core-3.1.2.jar