Repository: incubator-ratis Updated Branches: refs/heads/master 6d0d114ff -> 30cc77670
RATIS-132. Support simple 'mvn clean compile' command (move shading before the compile phase). Contributed by Elek, Marton Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/30cc7767 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/30cc7767 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/30cc7767 Branch: refs/heads/master Commit: 30cc776701561112d3761c4dcd143424897c4129 Parents: 6d0d114 Author: Tsz-Wo Nicholas Sze <[email protected]> Authored: Tue Nov 7 17:50:35 2017 -0800 Committer: Tsz-Wo Nicholas Sze <[email protected]> Committed: Tue Nov 7 17:50:35 2017 -0800 ---------------------------------------------------------------------- BUILDING.md | 14 +++++++------- ratis-hadoop-shaded/pom.xml | 9 ++++++--- ratis-proto-shaded/pom.xml | 40 +++++++++++++++++++++++++++++++++------- 3 files changed, 46 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/30cc7767/BUILDING.md ---------------------------------------------------------------------- diff --git a/BUILDING.md b/BUILDING.md index d1569bc..65585aa 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -13,21 +13,21 @@ --> # Building + Apache Ratis uses Apache Maven to build the artifacts. It is required to have Maven 3.3.9 or later. Apache Ratis is written in Java 8. Therefore, it as well requires Java 8 or later. -When building Ratis the first time, shaded files need to be generated by the following command: -``` -$ mvn package -DskipTests -``` -After that, `mvn compile` or `mvn test` can be used as normal. -For example, we may run the basic tests by +Project could be built as a usual maven project: + ``` -$ mvn test -Dtest=TestRaftWith\* +$ mvn clean package -DskipTests ``` +Note: subsequent builds could be faster with skiping shading/protobuf compile steps. +See the next section for more info. + # Shading We shade protos, protobuf and other libraries such as Netty, gRPC, Guava and Hadoop http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/30cc7767/ratis-hadoop-shaded/pom.xml ---------------------------------------------------------------------- diff --git a/ratis-hadoop-shaded/pom.xml b/ratis-hadoop-shaded/pom.xml index 1145942..8f9528b 100644 --- a/ratis-hadoop-shaded/pom.xml +++ b/ratis-hadoop-shaded/pom.xml @@ -186,13 +186,14 @@ <artifactId>maven-shade-plugin</artifactId> <executions> <execution> - <phase>package</phase> + <phase>process-resources</phase> <goals> <goal>shade</goal> </goals> <configuration> <shadeSourcesContent>true</shadeSourcesContent> <createSourcesJar>true</createSourcesJar> + <shadedArtifactAttached>true</shadedArtifactAttached> <relocations> <relocation> <pattern>com.google.protobuf</pattern> @@ -215,6 +216,8 @@ <artifactSet> <excludes> + <exclude>org.apache.ratis:ratis-hadoop-shaded</exclude> + <exclude>com.google.code.findbugs:jsr305</exclude> <exclude>com.google.code.gson:gson</exclude> <exclude>com.google.guava:guava</exclude> @@ -309,7 +312,7 @@ <executions> <execution> <id>unpack</id> - <phase>package</phase> + <phase>process-resources</phase> <goals> <goal>unpack</goal> </goals> @@ -319,7 +322,7 @@ <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> - <classifier>sources</classifier> + <classifier>shaded-sources</classifier> <type>jar</type> <overWrite>true</overWrite> <outputDirectory>${basedir}/${shaded.sources.dir}</outputDirectory> http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/30cc7767/ratis-proto-shaded/pom.xml ---------------------------------------------------------------------- diff --git a/ratis-proto-shaded/pom.xml b/ratis-proto-shaded/pom.xml index 4ec4713..8244239 100644 --- a/ratis-proto-shaded/pom.xml +++ b/ratis-proto-shaded/pom.xml @@ -484,9 +484,7 @@ <plugins> <!-- We are not cleaning the generated files from src/main/java since we do not check-in the - generated files there. Shading only happens in the build phase package (which is after - compile), so for mvn test and mvn compile to work, you should run mvn package or mvn - install one time so that src/main/java will be populated. + generated files there. --> <plugin> <groupId>org.xolstice.maven.plugins</groupId> @@ -495,10 +493,13 @@ <protocArtifact> com.google.protobuf:protoc:${shaded.protobuf.version}:exe:${os.detected.classifier} </protocArtifact> + <outputDirectory>src/main/java</outputDirectory> + <clearOutputDirectory>false</clearOutputDirectory> </configuration> <executions> <execution> <id>1</id> + <phase>generate-sources</phase> <goals> <goal>compile</goal> <goal>test-compile</goal> @@ -520,19 +521,42 @@ </execution> </executions> </plugin> - + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <phase>generate-sources</phase> + <configuration> + <tasks> + <replace token="com.google." value="org.apache.ratis.shaded.com.google." + dir="src/main/java/org/apache/ratis/shaded/proto"> + <include name="**/*.java"/> + </replace> + <replace token="io.grpc." value="org.apache.ratis.shaded.io.grpc." + dir="src/main/java/org/apache/ratis/shaded/proto"> + <include name="**/*.java"/> + </replace> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <executions> <execution> - <phase>package</phase> + <phase>process-resources</phase> <goals> <goal>shade</goal> </goals> <configuration> <shadeSourcesContent>true</shadeSourcesContent> <createSourcesJar>true</createSourcesJar> + <shadedArtifactAttached>true</shadedArtifactAttached> <relocations> <relocation> <pattern>com.google.common</pattern> @@ -567,6 +591,8 @@ <artifactSet> <excludes> + <exclude>org.apache.ratis:ratis-proto-shaded</exclude> + <exclude>com.barchart.udt:barchart-udt-bundle</exclude> <exclude>com.github.jponge:lzma-java</exclude> @@ -629,7 +655,7 @@ <executions> <execution> <id>unpack</id> - <phase>package</phase> + <phase>process-resources</phase> <goals> <goal>unpack</goal> </goals> @@ -639,7 +665,7 @@ <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> - <classifier>sources</classifier> + <classifier>shaded-sources</classifier> <type>jar</type> <overWrite>true</overWrite> <outputDirectory>${basedir}/${shaded.sources.dir}</outputDirectory>
