-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
unshaded jar contains Apache Ant, GSON, etc. #3896
Comments
It looks like you're right, c9f3d32 caused this in two ways:
Proposed fix would first be to first restore the removed dependencies, though instead of putting them in a parent pom, but them directly in the unshaded pom, and then replace the java_binary rule with something else that produces a jar which only contains closure-compiler contents. The pom contents as of that version are no longer correct, at least guava and protobuf-java are out of date it appears. My bazel knowledge is weak, but I can try to find/propose a rule that would only merge the types/resources declared (or generated) by this project. It looks like |
Here's a draft patch that produces a single un-shaded, un-ubered jar that only includes the java content of closure-compiler (and its various resources, like the externs zip and runtime_libs typedast) master...niloc132:3896-unshaded-jar The basic idea is to use rules_jvm_external's There are a few caveats for the patch as it stands:
I've done some minimal testing on this from a project which depends on closure-compiler as a library, but still should do more testing (to verify that the protobuf-java-util dependency isn't required, but I suspect it is...). I've taken this time to pause my work to seek at least an initial review, if this approach would be of interest as a contribution. -- Following the documentation of https://github.com/bazelbuild/rules_jvm_external/#publishing-to-external-repositories, it seemed that |
@niloc132 I've just read through your draft change diff. My primary concern is that we had a design goal to stop depending on maven for building, but this seems to be putting that dependency back in. Still, this may be OK.
Most of us do not work with tools like Maven in any other context, and so we will never be really familiar with its details. All of that is to paint a clear picture for you of what our concerns are, If you would like to create a PR, then I will be happy to review it and test it. Most likely, if it appears to work and my more in-depth review later doesn't make make me more concerned than I am now, I'll end up tweaking it a bit, then merging it. Thanks for the effort you put into this. |
I think your concerns are reasonable, which is why I didn't want to polish and submit it until someone else had a look. I haven't actively consulted any other bazel users (... mostly because I've never seen it used in the wild), but this appears to be the approach that bazelbuild/rules_jvm_external advises: using the I think that the two outputs, shaded and unshaded are reasonable, though as someone consuming closure-compiler as a library, I'm mostly interested in the unshaded output. Shaded output makes more sense I suspect when consuming the output as a binary (and as such, it is the java_binary rule that emits the jar, plus the jarjar rule to rename some packages defensively). Two last thoughts before I put together a PR: There are already lots of maven_import rules, so I don't feel terrible in adding one more, but perhaps I can find a different way to reference it. Second, I tried to make sure that the rules I touched/added only fed maven specific details into those sonatype bundled. The main place I failed here was the |
Thanks for bringing up those other concerns. I think it would be fine for you to create a PR with whatever you have right now. Once a PR exists I can import it and then test whether it breaks anything. It'll also be easier for me to really look at the changes in context once it is in PR form. |
until google/closure-compiler#3896 is resolved and the closure compiler properly does so
hey, is there any info what version doesn't have those extra packages ? |
@oleksiimiroshnyk which dependency are you using? the unshaded jar doesn't contain any direct/transitive dependencies, so shouldn't have this issue. On the other hand, you're then responsible for making sure you have compatible dependencies, but if you're using maven/gradle/ivy, that should more or less be resolved for you. That is, use groupid=com.google.javascript, artifactId=closure-compiler-unshaded, and whichever version of release you want to. |
@niloc132 thanks for your answer. Currently I'm having a project that is using quite old closure-compiler-unshaded v20210505 , and it has javax package that makes that project fail on startup. |
@oleksiimiroshnyk according to my PR linked to this, the fix for this was merged in 1291137, which can be found in versions v20221102 to v20230802, so start with v20221102? My company also maintains a closure-compiler fork with a few specific fixes that might be suitable for your use case. We backported the fix and released it on top of closure-compiler's v20220502 release, if you want to try something slightly older (with a few customized changes to it). This can be found in Maven central as |
Reported by Dominic in https://groups.google.com/g/closure-compiler-discuss/c/5ofdcVdWgQs
The unshaded jar should not contain copies of dependencies. Instead it should use dependencies from Maven. Copying the important details here:
The text was updated successfully, but these errors were encountered: