-
Notifications
You must be signed in to change notification settings - Fork 459
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
Consider shading the JGit dependency in Grade plugin #587
Comments
Hm, I thought Gradle had some classloader magic to isolate the plugins a bit, but such magic is always very fragile, so I don't doubt you! The gradle plugin consists of three artifacts, I think it's good for |
I'm not personally using Spotless's internals like |
As a workaround, you can try futzing with something like this: buildscript {
configurations.classpath {
resolutionStrategy {
force 'org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r'
}
}
} |
The workaround listed above works fine for me, any plans for a more permanent fix? |
The permanent fix is to shade everything except |
That is fair, it's not a huge issue, especially with the work around you have provided. I'll try and see if I can raise a PR if I can find the time to familiarise myself with the code base. Thanks. |
[editor's note: deleted a few off-topic comments to keep this issue focused on jgit shading and its workaround] |
FWIW, I'm not quite sure how |
This builds a shadow jar with all dependencies bundled in the plugin and relocates most dependencies under shadow. This will fix issues where other Gradle plugins uses incopatible versions of the same dependencis. Fixes diffplug#587
This builds a shadow jar with all dependencies bundled in the plugin and relocates most dependencies under shadow. This will fix issues where other Gradle plugins uses incompatible versions of the same dependencies. Fixes diffplug#587
Summary
In Gradle, all plugins share the same classpath. This makes it very hard, if not impossible, to use plugins which depend on different incompatible versions of the same library. This is the case with Spotless and GitPublish:
Downgrading the JGit dependency in Spotless, I believe, is not an option, but maybe you could consider shading this dependency, building it into the Gradle plugin JAR file? I believe that the official Gradle guidelines recommend minimizing the number of external dependencies, and shading is one of the ways to mitigate issues like this one.
Gradle version
Happens with any Gradle version, including the latest one, 6.4.1
Spotless version
4.0.1
Operating system and version
Probably not relevant, but macOS 10.15.3
Spotless configuration
Having something as simple as
in the build configuration will reproduce the issue,.
Console errors
In all my test cases any Spotless tasks don't cause errors; exceptions can be observed when the GitPublish plugin is used, and they are generic class linkage errors which happen when binary incompatible libraries with the same class names are present in the one classpath.
The text was updated successfully, but these errors were encountered: