Skip to content

Commit

Permalink
[build] Use absolute path to locate license and checkstyle plugin con…
Browse files Browse the repository at this point in the history
…fig (apache#8918)

### Motivation

Fixes apache#8911, compiling a sub module individually in the sub module directory
Previously, the maven build failed if executed in other than the root directory if the license or checkstyle checks were run since
those plugins weren't able to find their configuration.

### Modifications


- use proposed solution of https://stackoverflow.com/a/37965143
  to set a property `pulsar.basedir` which contains the absolute path
  to the root directory
  - all other solutions don't seem to work universally in all projects,
    for example `project.parent.basedir` isn't available in the
    root project and not all projects necessarily have the root project
    as their parent project.

- when running `license:check` or `checkstyle:checkstyle` directly,
  it is necessary to add `initialize` phase to the command line,
  since the `pulsar.basedir` property gets set in the `initialize` phase.
  for example:
  `mvn initialize license:check` or
  `mvn initialize checkstyle:checkstyle`
  - This should be fine since the maven best practice is to use lifecycle phases such 
    as `mvn verify` instead of listing plugin goals on the command line.
  • Loading branch information
lhotari authored Dec 13, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9405e6b commit ab35e2d
Showing 8 changed files with 49 additions and 147 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-license.yaml
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ jobs:

- name: build and check license
if: steps.docs.outputs.changed_only == 'no'
run: mvn -q -B -ntp -DskipTests license:check install
run: mvn -q -B -ntp -DskipTests initialize license:check install

- name: license check
if: steps.docs.outputs.changed_only == 'no'
65 changes: 46 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -203,6 +203,7 @@ flexible messaging model and an intuitive client API.</description>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<aspectj-maven-plugin.version>1.11.1</aspectj-maven-plugin.version>
<license-maven-plugin.version>4.0.rc2</license-maven-plugin.version>
<directory-maven-plugin.version>0.3.1</directory-maven-plugin.version>
<maven-enforcer-plugin.version>3.0.0-M2</maven-enforcer-plugin.version>
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
@@ -895,10 +896,10 @@ flexible messaging model and an intuitive client API.</description>
<version>${cassandra.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
</dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
@@ -1015,10 +1016,10 @@ flexible messaging model and an intuitive client API.</description>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
@@ -1119,14 +1120,36 @@ flexible messaging model and an intuitive client API.</description>
</configuration>
</plugin>

<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
<version>${directory-maven-plugin.version}</version>
<executions>
<execution>
<id>directories</id>
<goals>
<goal>directory-of</goal>
</goals>
<phase>initialize</phase>
<configuration>
<property>pulsar.basedir</property>
<project>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar</artifactId>
</project>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>
<configuration>
<licenseSets>
<licenseSet>
<header>src/license-header.txt</header>
<header>${pulsar.basedir}/src/license-header.txt</header>
<excludes>
<exclude>LICENSE</exclude>
<exclude>NOTICE</exclude>
@@ -1211,6 +1234,7 @@ flexible messaging model and an intuitive client API.</description>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
@@ -1431,9 +1455,10 @@ flexible messaging model and an intuitive client API.</description>
</dependency>
</dependencies>
<configuration>
<configLocation>buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<configLocation>${pulsar.basedir}/buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>${pulsar.basedir}/buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<excludes>**/proto/*</excludes>
</configuration>
</plugin>
<plugin>
@@ -1505,9 +1530,10 @@ flexible messaging model and an intuitive client API.</description>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>pulsar/suppressions.xml</suppressionsLocation>
<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
<configLocation>${pulsar.basedir}/buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>${pulsar.basedir}/buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<excludes>**/proto/*</excludes>
</configuration>
</plugin>
<plugin>
@@ -1563,11 +1589,12 @@ flexible messaging model and an intuitive client API.</description>
<execution>
<id>check-style</id>
<phase>verify</phase>
<configuration>
<configLocation>./buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>/buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
</configuration>
<configuration>
<configLocation>${pulsar.basedir}/buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>${pulsar.basedir}/buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<excludes>**/proto/*</excludes>
</configuration>
<goals>
<goal>check</goal>
</goals>
23 changes: 1 addition & 22 deletions pulsar-client-api/pom.xml
Original file line number Diff line number Diff line change
@@ -45,27 +45,6 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<configuration>
<configLocation>../buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>../buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
20 changes: 1 addition & 19 deletions pulsar-common/pom.xml
Original file line number Diff line number Diff line change
@@ -220,25 +220,7 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<configuration>
<configLocation>../buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>../buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<excludes>**/proto/*</excludes>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
18 changes: 0 additions & 18 deletions pulsar-package-management/pom.xml
Original file line number Diff line number Diff line change
@@ -40,24 +40,6 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<configuration>
<configLocation>../buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>../buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
22 changes: 0 additions & 22 deletions pulsar-sql/pom.xml
Original file line number Diff line number Diff line change
@@ -107,26 +107,4 @@
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<configuration>
<configLocation>../buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>../buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
23 changes: 0 additions & 23 deletions pulsar-transaction/coordinator/pom.xml
Original file line number Diff line number Diff line change
@@ -55,28 +55,5 @@
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<configuration>
<configLocation>../../buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>../../buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<excludes>**/proto/*</excludes>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
23 changes: 0 additions & 23 deletions pulsar-transaction/pom.xml
Original file line number Diff line number Diff line change
@@ -36,27 +36,4 @@
<module>coordinator</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<configuration>
<configLocation>../buildtools/src/main/resources/pulsar/checkstyle.xml</configLocation>
<suppressionsLocation>../buildtools/src/main/resources/pulsar/suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

0 comments on commit ab35e2d

Please sign in to comment.