shadow: ShadowJar not working with newer 'implementation' configuration
shadowJar task doesn’t works when using dependencies with newer ‘api’ or ‘implementation’ or ‘testImplementation’ configurations instead of ‘compile’ or ‘testCompile’ configuration.
for e.g:
shadowJar task is ineffective when using dependencies like:
dependencies { **implementation** 'org.apache.commons:commons-lang3:3.5' }
instead of:
dependencies { **compile** 'org.apache.commons:commons-lang3:3.5' }
Shadow Version
2+
Gradle Version
4.3+
Expected Behavior
Fat jar should be generated upon execution of shadowJar task
Actual Behavior
Fat jar not getting generated upon execution of shadowJar task
Gradle Build Script(s)
One sample snippet provided above and using following shadow task
shadowJar { classifier = '' baseName = artifactId destinationDir = file("${buildDir}/dist") manifest { attributes 'Implementation-Title': title, 'Implementation-Version': version, 'Main-Class': mainClassName } zip64 true }
Note: variable are defined under gradle.properties
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 19
- Comments: 23 (1 by maintainers)
A working workaround is to manually allow resolving
implementationconfiguration like this:P.S. I have no clue what consequences this action could have, but it at least does exactly what good ol’
compileconfiguration did. Use this at your own risk.You need
configurations.runtimeinstead, as it extends from bothcompileandimplementation.But why should you do that @qoomon? It is the same as using the
runtimeClasspathconfiguration which is resolvable and extends those two and would just work and also is the default used, so just remove the whole snippet you showed and it will work exactly the same, without abusing configurations that are not meant to be resolved.This is my working solution in kotlin
In fact, Gradle 7.0 still has this api
Doh! :–) Thanks for clarifying and for the tip!
@CharlieReitzel Did you see my code snippet? It’s clearly seen that my snippet enables direct resolving of
implementationconfiguration.I’m using this approach in my own project, and I can tell it does work.
We are using Gradle
5.0and having the same issue.