Skip to content

Commit

Permalink
RATIS-288. Pom cleanup/simplification. Contributed by Josh Elser
Browse files Browse the repository at this point in the history
  • Loading branch information
szetszwo committed Aug 7, 2018
1 parent 151c2ae commit 6a2c3d5
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 703 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -9,11 +9,9 @@
*.suo
*.vcxproj.user
.idea
.svn
.classpath
.project
.settings
target
build
patchprocess
dependency-reduced-pom.xml
42 changes: 24 additions & 18 deletions BUILDING.md
Expand Up @@ -19,7 +19,7 @@ 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.

Project could be built as a usual maven project:
Project could be built as a usual Maven project:

```
$ mvn clean package -DskipTests
Expand All @@ -34,34 +34,39 @@ We shade protos, protobuf and other libraries such as Netty, gRPC, Guava and Had
so that applications using Ratis may use protobuf and other libraries with versions
different from the versions used here.

Ratis requires the shaded sources for compilation.
The generated sources are stored in the following directories.
```
ratis-proto-shaded/src/main/java/
ratis-hadoop-shaded/src/main/java/
```
They are not checked-in to git though.
_Note: RATIS-288 changes how the shaded artifacts are generated, removing them from the
source tree. Developers with local checkouts prior to this change will need to manually
remove the directories `ratis-proto-shaded/src/main/java` and
`ratis-hadoop-shaded/src/main/java`._

By default protobuf compilation and shading are triggered at every build. To make more faster the
additional builds, you can turn them off:
By default, protobuf compilation and shaded jar creation are executed for every build.

For developers who wish to skip protobuf generation and shaded jar creation because they
are aware that they have not been modified, they can be disabled with the `skipShade` property.
```
$ mvn package -DskipTests -DskipShade
```

During the clean lifecycle all the shaded classes are also deleted. You can clean the
compiled files but keep the shaded classes with the following command:

When the `skipShade` property is given, Maven will inspect your local Maven repository for
the most recent version of `ratis-proto-shaded` (or `ratis-hadoop-shaded`), reaching out to
Maven central when you have no local copy. You may need to run a `mvn install` prior to
attempting to use the `skipShade` property to ensure that you have a version of the artifact
available for your use.
```
$ mvn clean -DskipCleanShade
$ mvn install -DskipTests
```

Then, the unit tests can be run by the following commands.
For developers familiar with the `skipCleanShade` option, this is no longer necessary. Maven's
local repository is acting as a cache instead of the current working copy of your repository.
`mvn clean` can be used to safely clean all temporary build files, without impacting your
use of the `skipShade` option.

Unit tests can also be executed with the `skipShade` option:
```
$ mvn -DskipShade test
$ mvn package -DskipShade
```

## What are shaded?
## What packages are shaded?

| Original packages | Shaded packages |
| ------------------------------------|--------------------------------------------------------------|
Expand All @@ -72,4 +77,5 @@ $ mvn -DskipShade test
| `io.netty` | `org.apache.ratis.shaded.io.netty` |
| `org.apache.hadoop.ipc.protobuf` | `org.apache.ratis.shaded.org.apache.hadoop.ipc.protobuf` |

The protos defined in this project are stored in the `org.apache.ratis.shaded.proto` package.
The compiled protocol-buffer definitions in this `ratis-proto-shaded` are stored in the
`org.apache.ratis.shaded.proto` Java package.
30 changes: 27 additions & 3 deletions pom.xml
Expand Up @@ -41,14 +41,12 @@
</licenses>

<modules>
<module>ratis-proto-shaded</module>
<module>ratis-common</module>
<module>ratis-client</module>
<module>ratis-server</module>

<module>ratis-grpc</module>
<module>ratis-netty</module>
<module>ratis-hadoop-shaded</module>
<module>ratis-hadoop</module>

<module>ratis-assembly</module>
Expand Down Expand Up @@ -322,6 +320,12 @@
<version>1.72</version>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.2.5</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -557,6 +561,13 @@
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<version>${apache-rat-plugin.version}</version>
<!-- target/ should get picked up from Apache parent pom.. -->
<configuration>
<!-- Lets us define more exclusions in child-modules without overriding these -->
<excludes combine.children="append">
<exclude>target/*</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -775,7 +786,8 @@
<artifactId>apache-rat-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<!-- Execution at the validate lifecycle is good -->
<id>check-licenses</id>
<goals>
<goal>check</goal>
</goals>
Expand All @@ -785,5 +797,17 @@
</plugins>
</build>
</profile>
<profile>
<id>skipShade</id>
<activation>
<property>
<name>!skipShade</name>
</property>
</activation>
<modules>
<module>ratis-proto-shaded</module>
<module>ratis-hadoop-shaded</module>
</modules>
</profile>
</profiles>
</project>
1 change: 0 additions & 1 deletion ratis-assembly/pom.xml
Expand Up @@ -21,7 +21,6 @@
</parent>

<artifactId>ratis-assembly</artifactId>
<groupId>org.apache.ratis</groupId>
<name>Apache Ratis Project Assembly</name>

<packaging>pom</packaging>
Expand Down
1 change: 0 additions & 1 deletion ratis-client/pom.xml
Expand Up @@ -38,7 +38,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
3 changes: 1 addition & 2 deletions ratis-common/pom.xml
Expand Up @@ -25,8 +25,8 @@

<dependencies>
<dependency>
<artifactId>ratis-proto-shaded</artifactId>
<groupId>org.apache.ratis</groupId>
<artifactId>ratis-proto-shaded</artifactId>
<scope>provided</scope>
</dependency>

Expand All @@ -53,7 +53,6 @@
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.2.5</version>
</dependency>

</dependencies>
Expand Down
38 changes: 1 addition & 37 deletions ratis-examples/pom.xml
Expand Up @@ -142,6 +142,7 @@
<goal>shade</goal>
</goals>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
Expand Down Expand Up @@ -181,41 +182,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>clean-shade</id>
<activation>
<property>
<name>!skipCleanShade</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>shaded-clean</id>
<goals>
<goal>clean</goal>
</goals>
<phase>clean</phase>
<configuration>
<filesets>
<fileset>
<directory>.</directory>
<includes>
<include>dependency-reduced-pom.xml</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
2 changes: 0 additions & 2 deletions ratis-hadoop-shaded/.gitignore

This file was deleted.

0 comments on commit 6a2c3d5

Please sign in to comment.