-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShadowJar not working with newer 'implementation' configuration #448
Comments
We are using Gradle |
Does it work if you tell it which configurations to use? shadowJar {
configurations = [project.configurations.implementation]
} |
@mig4 Unfortunately this throws an IllegalStateException. Please see the full stacktrace below
|
You need |
Custom tasks are not properly generating a fat jar with dependencies using shadow 5.0.0, gradle 5.4.1, and Java 8. Only the manifest and main class are included in the output jar. The main My use case is for generating a test jar so the example in the docs at https://imperceptiblethoughts.com/shadow/custom-tasks/ is exactly what I'm using. You should be able to reproduce this using that exact task definition in a bare project generated using the instructions at https://guides.gradle.org/creating-new-gradle-builds/ then choosing the options java-application, groovy for the build script DSL, and spock for the test framework. Changing the dependency declarations to use the old |
I run into the same exeception:
Any ideas how to fix this? I think this might be related to java-library plugin? |
A workaround I found: create a dummy configuration that extends from |
This is still happening. Any plans to fix this issue? Using the old configurations - compile, runtime, testCompile, testRuntime, etc. - brings the dependency classes into the fat jar. So it runs if I just put the fat jar in the $CLASSPATH. But running the jar fails because it's missing the main manifest attribute. |
A working workaround is to manually allow resolving shadowJar {
project.configurations.implementation.canBeResolved = true
configurations = [project.configurations.implementation]
// ...
} P.S. I have no clue what consequences this action could have, but it at least does exactly what good ol' |
@scpketer Did you see previous postings? Referring to the new style configuration name,
Using the old style configurations |
@CharlieReitzel Did you see my code snippet? It's clearly seen that my snippet enables direct resolving of
I'm using this approach in my own project, and I can tell it does work. |
Doh! :--) Thanks for clarifying and for the tip! |
In which file and directory do I place the shadowjar{} command. I don't see it referenced anywhere here and I am new to this stuff. |
@jcksnvllxr80 The |
still a problem with version 5.1 but scpketer workaround does the trick |
still a problem with version 5.2 |
Yes, unfortunately. |
@scpketer , the workaround with the implementation worked . I couldn't find any other alternate .. As we are getting the the compile is deprecated warning and will be removed in gradle 7.0 version , and yet the issue is not fixed with shadow plugin , i see this as the only option .. Thank you |
In fact, Gradle 7.0 still has this api // gradle.kts
project.configurations.implementation.get().isCanBeResolved = true |
Just wanted to poke this issue since it has been over a year since a comment was left and this issue still exists. I have recently been struggling with getting my custom shadow task to include the dependencies in the thick jar until I changed my configuration to use project.configurations.implementation.canBeResolved = true
configurations = [project.configurations.implementation] Prior to this build, my team used Gradle 6 and used the deprecated compile and runtime dependency declarations. We had also pointed our custom shadow task to use |
This is my working solution in kotlin withType<ShadowJar> {
// <WORKAROUND for="https://github.com/johnrengelman/shadow/issues/448">
configurations = listOf(
project.configurations.implementation.get(),
project.configurations.runtimeOnly.get()
).onEach { it.isCanBeResolved = true }
// </WORKAROUND>
} |
But why should you do that @qoomon? |
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
The text was updated successfully, but these errors were encountered: