You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider shading the JGit dependency in Grade plugin #587
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:
GitPublish depends on the "latest release" version, which for the latest version of the plugin itself is 5.6.0.201912101111-r
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
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.
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, lib with no dependencies, lib-extra with JGit and a few others, and then plugin-gradle which needs both of those.
I think it's good for lib to be pristine (allows people to build their own stuff and integrate easily), but I don't see any problem with shading everything else, including lib-extra, into plugin-gradle. Unless other contributors raise objections, I'd be happy to merge and release a PR that accomplished that.
I'm not personally using Spotless's internals like lib or lib-extra at this time, so I'm happy for any of the dependencies to be shaded into plugin-gradle. 👍
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.
Reacted by Ned Twigg, Isaac Vargas and Sumanth Chinthagunta
FWIW, I'm not quite sure how resolutionStrategy thing is a workaround - it will force another version, sure, but the issue with different plugins depending on different, binary incompatible versions of the same library remains: either spotless won't work, or gradle-git-publish (in this case).
Activity
nedtwigg commentedon May 30, 2020
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,
libwith no dependencies,lib-extrawith JGit and a few others, and thenplugin-gradlewhich needs both of those.I think it's good for
libto be pristine (allows people to build their own stuff and integrate easily), but I don't see any problem with shading everything else, includinglib-extra, intoplugin-gradle. Unless other contributors raise objections, I'd be happy to merge and release a PR that accomplished that.jbduncan commentedon May 30, 2020
I'm not personally using Spotless's internals like
liborlib-extraat this time, so I'm happy for any of the dependencies to be shaded intoplugin-gradle. 👍nedtwigg commentedon Jul 13, 2020
As a workaround, you can try futzing with something like this:
michaelruocco commentedon Aug 25, 2020
The workaround listed above works fine for me, any plans for a more permanent fix?
nedtwigg commentedon Aug 25, 2020
The permanent fix is to shade everything except
libintoplugin-gradle. It's very low on my todo list, but happy to merge and release a PR for it.michaelruocco commentedon Aug 25, 2020
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.
nedtwigg commentedon Mar 29, 2021
[editor's note: deleted a few off-topic comments to keep this issue focused on jgit shading and its workaround]
netvl commentedon Apr 1, 2021
FWIW, I'm not quite sure how
resolutionStrategything is a workaround - it will force another version, sure, but the issue with different plugins depending on different, binary incompatible versions of the same library remains: either spotless won't work, or gradle-git-publish (in this case).plugin-gradle: Build shadow jar and relocate most dependencies
plugin-gradle: Build shadow jar and relocate most dependencies