I’m trying to use the shadowJar plugin to create a jar which only contains all of the dependencies of my project but not my project’s code.
I’ve tried excluding my project from the dependencies with:
version = "1.0"
group = "com.pivotal"
shadowJar {
mergeServiceFiles()
dependencies {
exclude(dependency("com.pivotal:scratch:1.0"))
}
}
But that leaves me with only my code in the jar produced by the shadowJar task. Actually, it doesn’t matter what I put in that dependency, it only leaves me with my classes.
On a side note, I noticed some weirdness in that shadowJar produces different results when ‘dependencies { }’ comes after ‘shadowJar { }’ in my gradle file. Is this some Gradleism (sorry, I’m a noob here) or a bug?
The weirdness here is what I mentioned above - the presence of ‘exclude’ seems to only result in my classes in the resulting jar.
If you have an example project that exhibits the problem, that would be great, just post it to Github or wherever and put a link to it in the issue. (Or just post your build.gradle file in the issue)