-
Notifications
You must be signed in to change notification settings - Fork 403
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
Shadowed JARs should not be added to JAR manifest Class-Path header #324
Comments
We are hitting the same issue. We relocate protobuf and grpc under subfolder (sub-namespace), but they are still appearing in manifest, causing all sorts of problems or with Maven build, or tests, or runtime. Short of repackaging the resulting jar file I run out of ideas... |
This bug in the shadowJar task (probably introduced while fixing #65) was blocking me. Here is a workaround that others may find useful.
|
@sbrannen I don't understand where the issue here is. In the linked gradle file, you explicitly declare the |
So far for all the examples people have posted, this is behaving as intended. It seems like there is just a misunderstanding of when to use Specifically, that configuration is not intended to be a catch-all. It is very specifically for usage when you have a dependency that you don't know want merged into the shadow JAR, but is a required dependency to be shipped with the application. |
Thanks for following up. The documentation says, "Think of configurations.shadow as unmerged, runtime dependencies." In my case, one of the dependencies is the JDK's I don't want the huge
Now, if I run
Clients using the
If the client has set If I apply the workaround in my comment above, then clients are not broken. If the current behavior is intended, then how can I create a shadow jar file that is usable by clients but does not include the whole Thanks! |
@mernst Why do you need to declare a dependency to the JVM's You never have to declare libraries provided by the JVM as runtime dependencies. |
Unfortunately, this is incorrect. It ships with the JDK, but it is not part of the JRE nor the JVM and it is not on the default classpath.
If I omit it, the build fails with 12 errors like this:
Please try this, and you will see that the failure occurs when running either |
My mistake, if you aren't shipping it as part of the jar, how do you intend a user to have it then? |
What does "just omit the library" mean? I expected, from the documentation, that this is what the |
using |
If you're having issues with the behavior of
This should do it for you (maybe not exact). |
I showed this in a comment above:
There is no fixed location, and even if there was, there would be no fixed relative path. |
The suggestion of adding I suggest that it would be useful to update the manual with some of the useful information in this discussion: how to handle this use case (which has come up for several users), the assumption about shadowJar only works for dependendencies at a fixed relative location, and so forth. Even better would be to provide an option to |
@johnrengelman From the JUnit Team's point of view, this issue can be closed as "works-as-designed". Thanks! |
Original JUnit Issue
junit-team/junit5#1044
Code in Question
https://github.com/johnrengelman/shadow/blob/5e89b3d650f964e62a1b617223ee25d9001fa3d6/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy#L52-L54
Expected Behavior
Shadowed JARs should not be added to manifest Class-Path header.
Actual Behavior
Shadowed JARs are added to manifest Class-Path header.
Gradle Build Script(s)
https://github.com/junit-team/junit5/blob/master/junit-jupiter-params/junit-jupiter-params.gradle
Content of MANIFEST.MF
The text was updated successfully, but these errors were encountered: