From 4a4ed4202eac66bc288c8fcb2107b0608cc1e32f Mon Sep 17 00:00:00 2001 From: Marcelo Vanzin Date: Fri, 21 Nov 2014 12:25:15 -0800 Subject: [PATCH 1/4] [SPARK-4809] Rework Guava library shading. The current way of shading Guava is a little problematic. Code that depends on "spark-core" does not see the transitive dependency, yet classes in "spark-core" actually depend on Guava. So it's a little tricky to run unit tests that use spark-core classes, since you need a compatible version of Guava in your dependencies when running the tests. This can become a little tricky, and is kind of a bad user experience. This change modifies the way Guava is shaded so that it's applied uniformly across the Spark build. This means Guava is shaded inside spark-core itself, so that the dependency issues above are solved. Aside from that, all Spark sub-modules have their Guava references relocated, so that they refer to the relocated classes now packaged inside spark-core. Before, this was only done by the time the assembly was built, so project that did not end up inside the assembly (such as streaming backends) could still reference the original location of Guava classes). This relocation does not apply to the sub-modules under network/, though. For those cases, we want to keep the Guava dependency alive, since we want to use the same Guava as the rest of the Yarn NM when deploying the auxiliary shuffle service. For this reason, also, the network/ dependencies are shaded into the spark-core artifact too, so that the raw Guava dependency doesn't leak. --- assembly/pom.xml | 20 ------------- core/pom.xml | 50 +++++++++----------------------- examples/pom.xml | 64 +++++++++++------------------------------ network/common/pom.xml | 14 +++++---- network/shuffle/pom.xml | 10 +++++++ network/yarn/pom.xml | 2 ++ pom.xml | 16 ++++++++++- streaming/pom.xml | 18 ++++++++---- 8 files changed, 79 insertions(+), 115 deletions(-) diff --git a/assembly/pom.xml b/assembly/pom.xml index 4e2b773e7d2f3..c006d0d55f13b 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -43,12 +43,6 @@ - - - com.google.guava - guava - compile - org.apache.spark spark-core_${scala.binary.version} @@ -133,20 +127,6 @@ shade - - - com.google - org.spark-project.guava - - com.google.common.** - - - com/google/common/base/Absent* - com/google/common/base/Optional* - com/google/common/base/Present* - - - diff --git a/core/pom.xml b/core/pom.xml index 1feb00b3a7fb8..558b9387cbd37 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -368,42 +368,6 @@ true - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - false - - - com.google.guava:guava - - - - - - com.google.guava:guava - - com/google/common/base/Absent* - com/google/common/base/Optional* - com/google/common/base/Present* - - - - - - - - org.apache.maven.plugins maven-dependency-plugin @@ -426,6 +390,20 @@ + + org.apache.maven.plugins + maven-shade-plugin + + false + + + com.google.guava:guava + org.apache.spark:spark-network-common_${scala.binary.version} + org.apache.spark:spark-network-shuffle_${scala.binary.version} + + + + diff --git a/examples/pom.xml b/examples/pom.xml index 8713230e1e8ed..983e50b6dd887 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -35,12 +35,6 @@ http://spark.apache.org/ - - - com.google.guava - guava - compile - org.apache.spark spark-core_${scala.binary.version} @@ -322,12 +316,6 @@ - - com.google.guava:guava - - com/google/common/base/Optional* - - *:* @@ -337,42 +325,22 @@ + + + org.apache.commons.math3 + org.spark-project.commons.math3 + + + + + + reference.conf + + + log4j.properties + + - - - package - - shade - - - - - com.google - org.spark-project.guava - - com.google.common.** - - - com.google.common.base.Optional** - - - - org.apache.commons.math3 - org.spark-project.commons.math3 - - - - - - reference.conf - - - log4j.properties - - - - - @@ -416,7 +384,7 @@ - scala-2.10 diff --git a/network/common/pom.xml b/network/common/pom.xml index baca859fa5011..f1e6a105d727d 100644 --- a/network/common/pom.xml +++ b/network/common/pom.xml @@ -92,11 +92,6 @@ maven-jar-plugin 2.2 - - - test-jar - - test-jar-on-test-compile test-compile @@ -106,6 +101,15 @@ + + + org.apache.maven.plugins + maven-shade-plugin + + true + + + diff --git a/network/shuffle/pom.xml b/network/shuffle/pom.xml index 12468567c3aed..f746e96a75a1a 100644 --- a/network/shuffle/pom.xml +++ b/network/shuffle/pom.xml @@ -93,5 +93,15 @@ target/scala-${scala.binary.version}/classes target/scala-${scala.binary.version}/test-classes + + + + org.apache.maven.plugins + maven-shade-plugin + + + + + diff --git a/network/yarn/pom.xml b/network/yarn/pom.xml index acec8f18f2b5c..ba4bbf8c06631 100644 --- a/network/yarn/pom.xml +++ b/network/yarn/pom.xml @@ -76,6 +76,8 @@ + + diff --git a/pom.xml b/pom.xml index 6c1c1214a7d3e..87bb5c7ea0002 100644 --- a/pom.xml +++ b/pom.xml @@ -1094,7 +1094,10 @@ - + org.apache.maven.plugins maven-shade-plugin @@ -1105,6 +1108,17 @@ org.spark-project.spark:unused + + + com.google.common + org.spark-project.guava + + com/google/common/base/Absent* + com/google/common/base/Optional* + com/google/common/base/Present* + + + diff --git a/streaming/pom.xml b/streaming/pom.xml index b8b8f2e6cab65..7d75e3ce81585 100644 --- a/streaming/pom.xml +++ b/streaming/pom.xml @@ -77,14 +77,14 @@ org.scalatest scalatest-maven-plugin - - @@ -105,6 +105,14 @@ + + + org.apache.maven.plugins + maven-shade-plugin + + true + + From 107d7dac27ee4c9131588b8afabda3bc64902e80 Mon Sep 17 00:00:00 2001 From: Marcelo Vanzin Date: Tue, 6 Jan 2015 19:09:12 -0800 Subject: [PATCH 2/4] Add fix for SPARK-5052 (PR #3874). --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 2ee7dfdf816b0..e9b776d51f863 100644 --- a/pom.xml +++ b/pom.xml @@ -1086,8 +1086,10 @@ org.spark-project.guava com/google/common/base/Absent* + com/google/common/base/Function com/google/common/base/Optional* com/google/common/base/Present* + com/google/common/base/Supplier From b3104fcb12d5d85f7514f575beeb671816b02251 Mon Sep 17 00:00:00 2001 From: Marcelo Vanzin Date: Mon, 26 Jan 2015 13:52:04 -0800 Subject: [PATCH 3/4] Add comment. --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index fdf7d60375393..c34a4697e6ca8 100644 --- a/pom.xml +++ b/pom.xml @@ -1284,6 +1284,10 @@ com.google.common org.spark-project.guava + com/google/common/base/Absent* com/google/common/base/Function com/google/common/base/Optional* From 3c93e42a5e9474b33aa53f7fd6f22998d44a8c52 Mon Sep 17 00:00:00 2001 From: Marcelo Vanzin Date: Tue, 27 Jan 2015 17:02:40 -0800 Subject: [PATCH 4/4] Shade Guava in the network-common artifact. This makes all Spark-generated artifacts use the Guava defined in the build file at runtime too. The leaked classes ("Optional" and friends) are now exposed in a few places where they weren't before, but hopefully that won't cause issues. --- core/pom.xml | 24 ------------------------ network/common/pom.xml | 16 ++++++++++++---- network/shuffle/pom.xml | 11 ----------- network/yarn/pom.xml | 2 -- 4 files changed, 12 insertions(+), 41 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 42150ada65952..3c51b2d6b58f9 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -106,16 +106,6 @@ org.eclipse.jetty jetty-server - - - com.google.guava - guava - compile - org.apache.commons commons-lang3 @@ -372,20 +362,6 @@ - - org.apache.maven.plugins - maven-shade-plugin - - false - - - com.google.guava:guava - org.apache.spark:spark-network-common_${scala.binary.version} - org.apache.spark:spark-network-shuffle_${scala.binary.version} - - - - diff --git a/network/common/pom.xml b/network/common/pom.xml index 565bf822caac7..5a9bbe105d9f1 100644 --- a/network/common/pom.xml +++ b/network/common/pom.xml @@ -48,10 +48,15 @@ slf4j-api provided + com.google.guava guava - provided + compile @@ -96,13 +101,16 @@ - org.apache.maven.plugins maven-shade-plugin - true - + false + + + com.google.guava:guava + + diff --git a/network/shuffle/pom.xml b/network/shuffle/pom.xml index 36842ebe5ec6e..c2d0300ecd904 100644 --- a/network/shuffle/pom.xml +++ b/network/shuffle/pom.xml @@ -52,7 +52,6 @@ com.google.guava guava - provided @@ -88,15 +87,5 @@ target/scala-${scala.binary.version}/classes target/scala-${scala.binary.version}/test-classes - - - - org.apache.maven.plugins - maven-shade-plugin - - - - - diff --git a/network/yarn/pom.xml b/network/yarn/pom.xml index ba4bbf8c06631..acec8f18f2b5c 100644 --- a/network/yarn/pom.xml +++ b/network/yarn/pom.xml @@ -76,8 +76,6 @@ - -