diff --git a/assembly/pom.xml b/assembly/pom.xml index 9fbb037115db3d2e9119de00d8a71eae9656f915..de7b75258e3c5cb84b7a474c2050fae71c7769d0 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -43,6 +43,12 @@ </properties> <dependencies> + <!-- Promote Guava to compile scope in this module so it's included while shading. --> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <scope>compile</scope> + </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_${scala.binary.version}</artifactId> @@ -113,6 +119,18 @@ <goal>shade</goal> </goals> <configuration> + <relocations> + <relocation> + <pattern>com.google</pattern> + <shadedPattern>org.spark-project.guava</shadedPattern> + <includes> + <include>com.google.common.**</include> + </includes> + <excludes> + <exclude>com.google.common.base.Optional**</exclude> + </excludes> + </relocation> + </relocations> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> diff --git a/core/pom.xml b/core/pom.xml index 6d8be370377295df1632f5eafcccde5bc9e043a8..83c708dfc9619eefff22803fcdadb8ce05833c61 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -68,9 +68,15 @@ <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> </dependency> + <!-- + Promote Guava to "compile" so that maven-shade-plugin picks it up (for packaging the Optional + class exposed in the Java API). The plugin will then remove this dependency from the published + pom, so that Guava does not pollute the client's compilation classpath. + --> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> + <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> @@ -322,6 +328,35 @@ </arguments> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <shadedArtifactAttached>false</shadedArtifactAttached> + <artifactSet> + <includes> + <include>com.google.guava:guava</include> + </includes> + </artifactSet> + <filters> + <!-- See comment in the guava dependency declaration above. --> + <filter> + <artifact>com.google.guava:guava</artifact> + <includes> + <include>com/google/common/base/Optional*</include> + </includes> + </filter> + </filters> + </configuration> + </execution> + </executions> + </plugin> </plugins> <resources> diff --git a/examples/pom.xml b/examples/pom.xml index 8c4c128bb484d76ee25d13816c2bdf306c679f7a..9b12cb0c29c9fa31e9d3d2aa0d9d8721adc6cb28 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -46,8 +46,14 @@ </dependencies> </profile> </profiles> - + <dependencies> + <!-- Promote Guava to compile scope in this module so it's included while shading. --> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <scope>compile</scope> + </dependency> <dependency> <groupId>org.apache.spark</groupId> <artifactId>spark-core_${scala.binary.version}</artifactId> @@ -209,6 +215,12 @@ </includes> </artifactSet> <filters> + <filter> + <artifact>com.google.guava:guava</artifact> + <excludes> + <exclude>com/google/common/base/Optional*</exclude> + </excludes> + </filter> <filter> <artifact>*:*</artifact> <excludes> @@ -226,6 +238,18 @@ <goal>shade</goal> </goals> <configuration> + <relocations> + <relocation> + <pattern>com.google</pattern> + <shadedPattern>org.spark-project.guava</shadedPattern> + <includes> + <include>com.google.common.**</include> + </includes> + <excludes> + <exclude>com.google.common.base.Optional**</exclude> + </excludes> + </relocation> + </relocations> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> diff --git a/pom.xml b/pom.xml index 7ed07ad7df88df598d76970a4e2e64b4abdfc6bc..9cbf3ea5995c3d1091615f52a3cd0181653de3df 100644 --- a/pom.xml +++ b/pom.xml @@ -260,6 +260,7 @@ <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>14.0.1</version> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> @@ -1017,6 +1018,21 @@ <profiles> + <!-- + This profile is enabled automatically by the sbt built. It changes the scope for the guava + dependency, since we don't shade it in the artifacts generated by the sbt build. + --> + <profile> + <id>sbt</id> + <dependencies> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <scope>compile</scope> + </dependency> + </dependencies> + </profile> + <!-- Ganglia integration is not included by default due to LGPL-licensed code --> <profile> <id>spark-ganglia-lgpl</id> diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala index 49d52aefca17a910596307318b157e8ee0662ba8..4c696d3d385fb0c2cf0ae8a5429001273a0fc3aa 100644 --- a/project/SparkBuild.scala +++ b/project/SparkBuild.scala @@ -61,7 +61,7 @@ object SparkBuild extends PomBuild { def backwardCompatibility = { import scala.collection.mutable var isAlphaYarn = false - var profiles: mutable.Seq[String] = mutable.Seq.empty + var profiles: mutable.Seq[String] = mutable.Seq("sbt") if (Properties.envOrNone("SPARK_GANGLIA_LGPL").isDefined) { println("NOTE: SPARK_GANGLIA_LGPL is deprecated, please use -Pspark-ganglia-lgpl flag.") profiles ++= Seq("spark-ganglia-lgpl") @@ -116,7 +116,7 @@ object SparkBuild extends PomBuild { retrieveManaged := true, retrievePattern := "[type]s/[artifact](-[revision])(-[classifier]).[ext]", publishMavenStyle := true, - + resolvers += Resolver.mavenLocal, otherResolvers <<= SbtPomKeys.mvnLocalRepository(dotM2 => Seq(Resolver.file("dotM2", dotM2))), publishLocalConfiguration in MavenCompile <<= (packagedArtifacts, deliverLocal, ivyLoggingLevel) map { diff --git a/project/plugins.sbt b/project/plugins.sbt index 2a61f56c2ea607b533957431032acbcd785072a4..8096c61414660c068372f9033d8f95af2a162f12 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -26,3 +26,7 @@ addSbtPlugin("com.alpinenow" % "junit_xml_listener" % "0.5.1") addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.1") addSbtPlugin("com.cavorite" % "sbt-avro" % "0.3.2") + +libraryDependencies += "org.ow2.asm" % "asm" % "5.0.3" + +libraryDependencies += "org.ow2.asm" % "asm-commons" % "5.0.3"