[
https://issues.apache.org/jira/browse/BEAM-4860?focusedWorklogId=127764&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-127764
]
ASF GitHub Bot logged work on BEAM-4860:
----------------------------------------
Author: ASF GitHub Bot
Created on: 26/Jul/18 14:09
Start Date: 26/Jul/18 14:09
Worklog Time Spent: 10m
Work Description: iemejia closed pull request #6064: [BEAM-4860] Ensure
that shaded artifacts that are produced don't leak non org.apache.beam classes
URL: https://github.com/apache/beam/pull/6064
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
index 23e96a27e28..d3f02dd5bfb 100644
--- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
@@ -68,6 +68,15 @@ class BeamModulePlugin implements Plugin<Project> {
/** Controls whether tests are run with shadowJar. */
boolean testShadowJar = false
+ /**
+ * Controls whether the shadow jar is validated to not contain any classes
outside the org.apache.beam namespace.
+ * This protects artifact jars from leaking dependencies classes causing
conflicts for users.
+ *
+ * Note that this can be disabled for subprojects that produce application
artifacts that are not intended to
+ * be depended on by users.
+ */
+ boolean validateShadowJar = true
+
/**
* The shadowJar / shadowTestJar tasks execute the following closure to
configure themselves.
* Users can compose their closure with the default closure via:
@@ -452,6 +461,7 @@ class BeamModulePlugin implements Plugin<Project> {
dependencies {
include(dependency(project.library.java.guava))
}
+ // guava uses the com.google.common and com.google.thirdparty package
namespaces
relocate("com.google.common",
project.getJavaRelocatedPath("com.google.common")) {
// com.google.common is too generic, need to exclude guava-testlib
exclude "com.google.common.collect.testing.**"
@@ -459,6 +469,7 @@ class BeamModulePlugin implements Plugin<Project> {
exclude "com.google.common.testing.**"
exclude "com.google.common.util.concurrent.testing.**"
}
+ relocate "com.google.thirdparty",
project.getJavaRelocatedPath("com.google.thirdparty")
}
// Configures a project with a default set of plugins that should apply to
all Java projects.
@@ -713,6 +724,24 @@ class BeamModulePlugin implements Plugin<Project> {
project.test { classpath =
project.configurations.shadowTestRuntimeClasspath }
}
+ if (configuration.validateShadowJar) {
+ project.task('validateShadedJarDoesntLeakNonOrgApacheBeamClasses',
dependsOn: 'shadowJar') {
+ inputs.files project.configurations.shadow.artifacts.files
+ doLast {
+ project.configurations.shadow.artifacts.files.each {
+ FileTree exposedClasses = project.zipTree(it).matching {
+ include "**/*.class"
+ exclude "org/apache/beam/**"
+ }
+ if (exposedClasses.files) {
+ throw new GradleException("$it exposed classes outside of
org.apache.beam namespace: ${exposedClasses.files}")
+ }
+ }
+ }
+ }
+ project.tasks.check.dependsOn
project.tasks.validateShadedJarDoesntLeakNonOrgApacheBeamClasses
+ }
+
if ((isRelease(project) || project.hasProperty('publishing')) &&
configuration.publish) {
project.apply plugin: "maven-publish"
@@ -1330,23 +1359,6 @@ artifactId=${project.name}
shadow 'com.google.errorprone:error_prone_annotations:2.1.2'
}
- project.task('validateShadedJarDoesntLeakNonOrgApacheBeamClasses',
dependsOn: ['shadowJar', 'shadowTestJar']) {
- inputs.files project.configurations.shadow.artifacts.files
- inputs.files project.configurations.shadowTest.artifacts.files
- doLast {
- (project.configurations.shadow.artifacts.files +
project.configurations.shadowTest.artifacts.files).each {
- FileTree exposedClasses = project.zipTree(it).matching {
- include "**/*.class"
- exclude "org/apache/beam/**"
- }
- if (exposedClasses.files) {
- throw new GradleException("$it exposed classes outside of
org.apache.beam namespace: ${exposedClasses.files}")
- }
- }
- }
- }
- project.tasks.check.dependsOn
project.tasks.validateShadedJarDoesntLeakNonOrgApacheBeamClasses
-
// TODO(BEAM-4544): Integrate intellij support into this.
}
diff --git a/runners/flink/job-server/build.gradle
b/runners/flink/job-server/build.gradle
index 552e04c3d74..8bb2bc537ec 100644
--- a/runners/flink/job-server/build.gradle
+++ b/runners/flink/job-server/build.gradle
@@ -18,6 +18,7 @@
apply plugin: org.apache.beam.gradle.BeamModulePlugin
applyJavaNature(
+ validateShadowJar: false,
shadowClosure: {
append "reference.conf"
},
diff --git a/sdks/java/extensions/sql/jdbc/build.gradle
b/sdks/java/extensions/sql/jdbc/build.gradle
index 3a894cc01bd..46c90e0c3c2 100644
--- a/sdks/java/extensions/sql/jdbc/build.gradle
+++ b/sdks/java/extensions/sql/jdbc/build.gradle
@@ -17,7 +17,7 @@
*/
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(testShadowJar: true, shadowClosure: {})
+applyJavaNature(testShadowJar: true, validateShadowJar: false, shadowClosure:
{})
configurations {
integrationTest
diff --git a/sdks/java/harness/build.gradle b/sdks/java/harness/build.gradle
index ce6b2db3370..83cc4be1576 100644
--- a/sdks/java/harness/build.gradle
+++ b/sdks/java/harness/build.gradle
@@ -26,7 +26,7 @@ def dependOnProjects = [":beam-model-pipeline",
":beam-model-fn-execution", ":be
":beam-runners-core-java",
":beam-runners-core-construction-java"]
apply plugin: org.apache.beam.gradle.BeamModulePlugin
-applyJavaNature(shadowClosure: DEFAULT_SHADOW_CLOSURE <<
+applyJavaNature(validateShadowJar: false, shadowClosure:
DEFAULT_SHADOW_CLOSURE <<
// Create an uber jar without repackaging for the SDK harness
// TODO: We have been releasing this in the past, consider not
// releasing it since its typically bad practice to release 'all'
diff --git a/vendor/sdks-java-extensions-protobuf/build.gradle
b/vendor/sdks-java-extensions-protobuf/build.gradle
index b6c3d676dcc..a34296b910c 100644
--- a/vendor/sdks-java-extensions-protobuf/build.gradle
+++ b/vendor/sdks-java-extensions-protobuf/build.gradle
@@ -54,20 +54,3 @@ dependencies {
compile 'com.google.protobuf:protobuf-java:3.5.1'
shadow project(path: ":beam-sdks-java-core", configuration: "shadow")
}
-
-task('validateShadedJarDoesntLeakNonOrgApacheBeamClasses', dependsOn:
['shadowJar', 'shadowTestJar']) {
- inputs.files configurations.shadow.artifacts.files
- inputs.files configurations.shadowTest.artifacts.files
- doLast {
- (configurations.shadow.artifacts.files +
configurations.shadowTest.artifacts.files).each {
- FileTree exposedClasses = zipTree(it).matching {
- include "**/*.class"
- exclude "org/apache/beam/**"
- }
- if (exposedClasses.files) {
- throw new GradleException("$it exposed classes outside of
org.apache.beam namespace: ${exposedClasses.files}")
- }
- }
- }
-}
-tasks.check.dependsOn tasks.validateShadedJarDoesntLeakNonOrgApacheBeamClasses
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 127764)
Time Spent: 40m (was: 0.5h)
> com/google/thirdparty/publicsuffix is not shaded along with guava
> -----------------------------------------------------------------
>
> Key: BEAM-4860
> URL: https://issues.apache.org/jira/browse/BEAM-4860
> Project: Beam
> Issue Type: Bug
> Components: build-system
> Affects Versions: 2.5.0
> Reporter: Fred Wulff
> Assignee: Luke Cwik
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> com.google.common is shaded, but com.google.thirdparty.publicsuffix (which is
> part of the guava library) is not, so attempting to use a more recent version
> of Guava while importing the beam libraries leads to conflicts
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)