I have a base project that builds a jar and then leaf projects that build from that and package up a zip for distribution to a server. Some of the base project’s dependencies should be packaged into the leaf project’s zip, but others are provided on the server and should not be. I’m not sure how to exclude those dependencies and their transitive dependencies?
My setup looks something like: Root build.gradle:
List A ["org.acme.blah", "org.acme.blahblah"]
dependencies {
compile A
compile('B') {
exclude group 'these.guys.suck'
}
compile C,D,E
}
Leaf project build.gradle:
dependencies {
compile project(':')
}
task distForServer(type: Zip) {
from configurations.runtime,
configurations.default.allArtifacts.files,
sourceSets.main.resources
exclude A,B <-- (and their dependencies) How to do this?
}
I need the distForServer artifact to include :'s artifacts, the leaf project’s artifacts, C,D,E and C,D,E’s transitive dependencies. I know it’s not preferred to have code in ‘:’, and if necessary I can re-factor, but it’d be better to leave as is.
Note the copyRecursive call before the exclude call. Without this we actually make the exclude global, i.e. if you run the two tasks after each other (and the distWithExclude task executes first) then both zip files will have the smaller foot print…since we told gradle to modify the ‘runtime’ configuration and exclude everything with the group ‘asm’.
Gradle gurus, feel free to chime in if there is a cleaner way…and feel free to let me know if this solves your problem or if I misunderstood your issue.