Created
April 15, 2014 23:23
-
-
Save guenter/10788301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configure.ac b/configure.ac | |
index c1de6d7..3197d00 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -436,6 +436,13 @@ __EOF__ | |
AC_DEFINE([MESOS_HAS_JAVA]) | |
has_java=yes | |
+ | |
+ # Test for Maven so we can build the jar | |
+ AC_MSG_CHECKING([whether we have Maven]) | |
+ AC_CHECK_PROG(MVN_CHECK, mvn, yes) | |
+ if test x"$MVN_CHECK" != x"yes"; then | |
+ AC_MSG_ERROR([Unable to find mvn on your path.]) | |
+ fi | |
fi | |
AM_CONDITIONAL([HAS_JAVA], [test "x$has_java" = "xyes"]) | |
diff --git a/src/Makefile.am b/src/Makefile.am | |
index 560b4c7..49eec17 100644 | |
--- a/src/Makefile.am | |
+++ b/src/Makefile.am | |
@@ -547,7 +547,7 @@ EXTRA_DIST += deploy/mesos-deploy-env.sh.template \ | |
# to EXTRA_DIST unconditionally. | |
# Mesos JAR. | |
-MESOS_JAR = mesos-$(PACKAGE_VERSION).jar | |
+MESOS_JAR = java/target/mesos-$(PACKAGE_VERSION).jar | |
MESOS_JAR_SOURCE = \ | |
$(srcdir)/java/src/org/apache/mesos/ExecutorDriver.java \ | |
$(srcdir)/java/src/org/apache/mesos/Executor.java \ | |
@@ -562,6 +562,8 @@ MESOS_JAR_SOURCE = \ | |
$(srcdir)/java/src/org/apache/mesos/state/State.java \ | |
$(srcdir)/java/src/org/apache/mesos/state/Variable.java \ | |
$(srcdir)/java/src/org/apache/mesos/state/ZooKeeperState.java | |
+ | |
+MESOS_SOURCES_JAR = java/target/mesos-$(PACKAGE_VERSION)-sources.jar | |
MESOS_JAR_GENERATED = $(JAVA_PROTOS) \ | |
java/generated/org/apache/mesos/MesosNativeLibrary.java | |
EXTRA_DIST += $(MESOS_JAR_SOURCE) \ | |
@@ -579,47 +581,17 @@ EXTRA_DIST += $(EXAMPLES_SOURCE) | |
if HAS_JAVA | |
-# Protocol buffers JAR. | |
-PROTOBUF_JAR = ../protobuf-$(PROTOBUF_VERSION).jar | |
- | |
-# TODO(charles): Move into 3rdparty/Makefile.am. | |
-$(PROTOBUF_JAR): # TODO(charles): Specify dependencies for the jar. | |
- @echo "Building protobuf-$(PROTOBUF_VERSION).jar ..." | |
- $(MKDIR_P) ../$(PROTOBUF)/java/src/main/java | |
- $(PROTOC) --java_out=../$(PROTOBUF)/java/src/main/java \ | |
- -I../$(PROTOBUF)/src \ | |
- ../$(PROTOBUF)/src/google/protobuf/descriptor.proto | |
- $(JAVA_HOME)/bin/javac -source 1.6 -target 1.6 \ | |
- -d ../$(PROTOBUF)/java/src/main/java \ | |
- ../$(PROTOBUF)/java/src/main/java/com/google/protobuf/*.java \ | |
- ../$(PROTOBUF)/java/src/main/java/com/google/protobuf/*.java | |
- $(JAVA_HOME)/bin/jar cf $@ -C ../$(PROTOBUF)/java/src/main/java com | |
- | |
-CLEANFILES += $(PROTOBUF_JAR) | |
- | |
-$(MESOS_JAR): $(MESOS_JAR_SOURCE) $(MESOS_JAR_GENERATED) $(PROTOBUF_JAR) | |
+$(MESOS_JAR): $(MESOS_JAR_SOURCE) $(MESOS_JAR_GENERATED) | |
@echo "Building mesos-$(PACKAGE_VERSION).jar ..." | |
- -rm -rf java/classes/org/apache/mesos | |
- $(MKDIR_P) java/classes/org/apache/mesos | |
- $(JAVA_HOME)/bin/javac -source 1.6 -target 1.6 \ | |
- -cp $(PROTOBUF_JAR) \ | |
- -d java/classes $(MESOS_JAR_SOURCE) $(MESOS_JAR_GENERATED) | |
- $(JAVA_HOME)/bin/jar cf $@ -C java/classes org | |
+ @cd java | |
+ mvn -f mesos.pom package | |
-CLEANFILES += $(MESOS_JAR) | |
- | |
- | |
-MESOS_SOURCES_JAR = ../src/mesos-$(PACKAGE_VERSION)-sources.jar | |
- | |
-$(MESOS_SOURCES_JAR): $(MESOS_JAR_SOURCE) | |
- -rm -f $(MESOS_SOURCES_JAR) | |
- $(JAVA_HOME)/bin/jar cf $@ -C $(srcdir)/java/src org | |
- $(JAVA_HOME)/bin/jar uf $@ -C java/generated org | |
+$(MESOS_SOURCES_JAR): $(MESOS_JAR) | |
+CLEANFILES += $(MESOS_JAR) | |
CLEANFILES += $(MESOS_SOURCES_JAR) | |
- | |
# Convenience library for JNI bindings. | |
# TODO(Charles Reiss): We really should be building the Java library | |
# with -module, which means it should be a different library than the | |
diff --git a/src/java/mesos.pom.in b/src/java/mesos.pom.in | |
index 8f9b747..1205bb6 100644 | |
--- a/src/java/mesos.pom.in | |
+++ b/src/java/mesos.pom.in | |
@@ -94,19 +94,17 @@ | |
</resource> | |
</resources> | |
<plugins> | |
- <!-- Skip compile:compile by re-binding it to a non-standard (made-up) | |
- phase. --> | |
<plugin> | |
+ <groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
+ <version>3.1</version> | |
<configuration> | |
<target>1.6</target> | |
+ <includes> | |
+ <include>@abs_top_srcdir@/src/java/src/**/*.java</include> | |
+ <include>@abs_top_srcdir@/src/java/generated/**/*.java</include> | |
+ </includes> | |
</configuration> | |
- <executions> | |
- <execution> | |
- <id>default-compile</id> | |
- <phase>never</phase> | |
- </execution> | |
- </executions> | |
</plugin> | |
<!-- Skip tests entirely --> | |
<plugin> | |
@@ -170,6 +168,42 @@ | |
</execution> | |
</executions> | |
</plugin> | |
+ <!-- Shade protobuf dependency. --> | |
+ <plugin> | |
+ <groupId>org.apache.maven.plugins</groupId> | |
+ <artifactId>maven-shade-plugin</artifactId> | |
+ <version>2.2</version> | |
+ <executions> | |
+ <execution> | |
+ <phase>package</phase> | |
+ <goals> | |
+ <goal>shade</goal> | |
+ </goals> | |
+ <configuration> | |
+ <artifactSet> | |
+ <includes> | |
+ <include>com.google.protobuf:protobuf-java</include> | |
+ </includes> | |
+ </artifactSet> | |
+ <filters> | |
+ <filter> | |
+ <!-- Remove the source to keep the result smaller. --> | |
+ <artifact>com.google.protobuf:protobuf-java</artifact> | |
+ <excludes> | |
+ <exclude>**/*.java</exclude> | |
+ </excludes> | |
+ </filter> | |
+ </filters> | |
+ <relocations> | |
+ <relocation> | |
+ <pattern>com.google.protobuf</pattern> | |
+ <shadedPattern>org.apache.mesos.com.google.protobuf</shadedPattern> | |
+ </relocation> | |
+ </relocations> | |
+ </configuration> | |
+ </execution> | |
+ </executions> | |
+ </plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment