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

Commit

Permalink
Merge pull request #209 from launchdarkly/eb/ch73967/javax-shading
Browse files Browse the repository at this point in the history
fix shading problem with javax classes
  • Loading branch information
eli-darkly authored Apr 17, 2020
2 parents 49cf6df + e239121 commit d274337
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,19 @@ def getPackagesInDependencyJar(jarFile) {
// phase; instead we have to run it after configuration, with the "afterEvaluate" block below.
def shadeDependencies(jarTask) {
def excludePackages = getAllSdkPackages() +
configurations.shadow.collectMany { getPackagesInDependencyJar(it)}
configurations.shadow.collectMany { getPackagesInDependencyJar(it) }
def topLevelPackages =
configurations.internal.collectMany {
getPackagesInDependencyJar(it).collect { it.contains(".") ? it.substring(0, it.indexOf(".")) : it }
}.
unique()
topLevelPackages.forEach { top ->
jarTask.relocate(top, "com.launchdarkly.shaded." + top) {
// This special-casing for javax.annotation is hacky, but the issue is that Guava pulls in a jsr305
// implementation jar that provides javax.annotation, and we *do* want to embed and shade those classes
// so that Guava won't fail to find them and they won't conflict with anyone else's version - but we do
// *not* want references to any classes from javax.net, javax.security, etc. to be munged.
def packageToRelocate = (top == "javax") ? "javax.annotation" : top
jarTask.relocate(packageToRelocate, "com.launchdarkly.shaded." + packageToRelocate) {
excludePackages.forEach { exclude(it + ".*") }
}
}
Expand Down

0 comments on commit d274337

Please sign in to comment.