Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit d274337

Browse files
authored
Merge pull request #209 from launchdarkly/eb/ch73967/javax-shading
fix shading problem with javax classes
2 parents 49cf6df + e239121 commit d274337

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,19 @@ def getPackagesInDependencyJar(jarFile) {
253253
// phase; instead we have to run it after configuration, with the "afterEvaluate" block below.
254254
def shadeDependencies(jarTask) {
255255
def excludePackages = getAllSdkPackages() +
256-
configurations.shadow.collectMany { getPackagesInDependencyJar(it)}
256+
configurations.shadow.collectMany { getPackagesInDependencyJar(it) }
257257
def topLevelPackages =
258258
configurations.internal.collectMany {
259259
getPackagesInDependencyJar(it).collect { it.contains(".") ? it.substring(0, it.indexOf(".")) : it }
260260
}.
261261
unique()
262262
topLevelPackages.forEach { top ->
263-
jarTask.relocate(top, "com.launchdarkly.shaded." + top) {
263+
// This special-casing for javax.annotation is hacky, but the issue is that Guava pulls in a jsr305
264+
// implementation jar that provides javax.annotation, and we *do* want to embed and shade those classes
265+
// so that Guava won't fail to find them and they won't conflict with anyone else's version - but we do
266+
// *not* want references to any classes from javax.net, javax.security, etc. to be munged.
267+
def packageToRelocate = (top == "javax") ? "javax.annotation" : top
268+
jarTask.relocate(packageToRelocate, "com.launchdarkly.shaded." + packageToRelocate) {
264269
excludePackages.forEach { exclude(it + ".*") }
265270
}
266271
}

0 commit comments

Comments
 (0)