This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 6953f53fb1f0ef617f596ec89690ab0e1adfc4e4
Author: Grant Henke <[email protected]>
AuthorDate: Tue Sep 15 11:09:09 2020 -0500

    KUDU-3157: Ensure we don’t shade slf4j classes
    
    We should almost never shade slf4j classes but due to a behavior
    issue in the Shadow Gradle plugin, exclusions from parent
    modules are not respected in modules that use them. This meant
    that we were shading slf4j classes into the kudu-spark module
    jars and any modules that depend on kudu-spark.
    
    This patch fixes the issue by universally excluding slf4j from
    being shaded unless `shadowIncludeSlf4j` is explicitly specified.
    Currently we only do this in the kudu-subrocess module.
    
    Change-Id: I72605594bdc70670f82eff4154247c5c0252de7f
    Reviewed-on: http://gerrit.cloudera.org:8080/16453
    Tested-by: Grant Henke <[email protected]>
    Reviewed-by: Grant Henke <[email protected]>
---
 java/gradle/shadow.gradle         | 17 +++++++++++++++++
 java/kudu-subprocess/build.gradle |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/java/gradle/shadow.gradle b/java/gradle/shadow.gradle
index 5d9eb18..9eb6cfd 100644
--- a/java/gradle/shadow.gradle
+++ b/java/gradle/shadow.gradle
@@ -26,6 +26,11 @@ knows.enabled = false // Disable the "easter egg" knows task.
 knows.group = "" // Hide the "easter egg" knows task.
 shadowJar.group = "" // Hide shadowJar task since it's used by the default 
build.
 
+// Add a property to explicitly allow slf4j shading.
+ext {
+  shadowIncludeSlf4j = false
+}
+
 // Configure a shaded jar to replace the default jar
 shadowJar.classifier = null // Configure shadow jar to have the default 
classifier.
 jar.finalizedBy(shadowJar)  // Generate the shaded jar anytime the jar task is 
run.
@@ -94,6 +99,18 @@ afterEvaluate {
       }
     }
   }
+
+  // Ensure we never shade SLF4J unless we explicitly specify it.
+  // This is a workaround because in the shadow plugin exclusions from
+  // parent modules are not respected in modules that use them.
+  if (!shadowIncludeSlf4j) {
+    shadowJar {
+      dependencies {
+        exclude(dependency("org.slf4j:slf4j-api:.*"))
+      }
+    }
+  }
+
   // Ensure compileUnshaded dependencies are not compiled into shadowJar.
   project.configurations.compileUnshaded.dependencies.each { dep ->
     def depStr = "${dep.group}:${dep.name}:${dep.version}"
diff --git a/java/kudu-subprocess/build.gradle 
b/java/kudu-subprocess/build.gradle
index 1a9cdca..4463cc2 100644
--- a/java/kudu-subprocess/build.gradle
+++ b/java/kudu-subprocess/build.gradle
@@ -18,6 +18,9 @@
 apply from: "$rootDir/gradle/protobuf.gradle"
 apply from: "$rootDir/gradle/shadow.gradle"
 
+// Explicitly allow slf4j to be included in this jar.
+shadowIncludeSlf4j = true
+
 dependencies {
   compile(libs.hadoopCommon) {
     // hadoopCommon and rangerPlugin use different versions of jersey.

Reply via email to