Skip to content

Commit

Permalink
GH-169: Use parent POM in ITs and fix checkstyle/license header valid…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
ascopes committed Apr 20, 2024
1 parent ba11221 commit e7a2153
Show file tree
Hide file tree
Showing 33 changed files with 465 additions and 466 deletions.
227 changes: 145 additions & 82 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<immutables.version>2.10.1</immutables.version>
<jspecify.version>0.3.0</jspecify.version>
<junit.version>5.10.2</junit.version>
<kotlin.version>1.9.21</kotlin.version>
<maven-core.version>3.9.6</maven-core.version>
<maven-plugin-annotations.version>3.12.0</maven-plugin-annotations.version>
<maven-plugin-api.version>3.9.6</maven-plugin-api.version>
Expand All @@ -121,6 +122,7 @@
<maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-gpg-plugin.version>3.2.1</maven-gpg-plugin.version>
<maven-install-plugin.version>3.1.1</maven-install-plugin.version>
<maven-invoker-plugin.version>3.6.1</maven-invoker-plugin.version>
<maven-jar-plugin.version>3.4.0</maven-jar-plugin.version>
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
Expand Down Expand Up @@ -192,6 +194,15 @@
<version>${immutables.version}</version>
</dependency>

<dependency>
<!-- Used for integration tests that invoke the Kotlin compiler only. -->
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>${kotlin.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>

<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
Expand Down Expand Up @@ -228,103 +239,111 @@
<!-- Plugins to run on all subprojects implicitly. -->
<plugins>
<plugin>
<!-- Enforces our license header and allows adding it automatically to code. -->
<!-- This is an aggregate so only needs to be applied once. -->
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>

<configuration>
<!-- Useful flags: https://mycila.carbou.me/license-maven-plugin/ -->
<licenseSets>
<licenseSet>
<header>.mvn/license/license-header.txt</header>
<includes>
<include>src/**/*.groovy</include>
<include>src/**/*.java</include>
<include>src/**/*.kt</include>
<include>src/**/*.properties</include>
<include>src/**/*.proto</include>
<include>**/*.xml</include>
</includes>
<excludes>
<exclude>.mvn/checkstyle/checkstyle.xml</exclude>
</excludes>
</licenseSet>
</licenseSets>
<mapping>
<java>SLASHSTAR_STYLE</java>
</mapping>
<properties>
<currentYear>2024</currentYear>
<inceptionYear>${project.inceptionYear}</inceptionYear>
</properties>
<strictCheck>true</strictCheck>
</configuration>

<executions>
<execution>
<id>validate-license-headers</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<inherited>false</inherited>
</plugin>

<plugin>
<!-- Checking style of code matches the Google code style. -->
<!-- This has no option for aggregation but derived projects must specify the
relativePath attribute so that locations of the checkstyle config file resolve
correctly from the parent in ITs -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>

<configuration>
<configLocation>.mvn/checkstyle/checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<includeResources>true</includeResources>
<sourceDirectories>${project.basedir}/src</sourceDirectories>
<suppressionsLocation>.mvn/checkstyle/suppressions.xml</suppressionsLocation>
<violationSeverity>info</violationSeverity>
</configuration>

<executions>
<execution>
<id>check-code-style</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>

<dependencies>
<dependency>
<!-- Force the usage of checkstyle v10 rather than v8.28 -->
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<!-- Deployments and version incrementing. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<!-- These are run in the prepare phase already so don't run them twice -->
<arguments>-Dmaven.test.skip -Dinvoker.skip</arguments>
<goals>deploy</goals>
<releaseProfiles>gpg</releaseProfiles>
</configuration>
</plugin>
</plugins>

<!-- Management for optional plugins. -->
<pluginManagement>
<plugins>
<plugin>
<!-- Enforces our license header and allows adding it automatically to code. -->
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>

<configuration>
<!-- Useful flags: https://mycila.carbou.me/license-maven-plugin/ -->
<aggregate>true</aggregate>
<licenseSets>
<licenseSet>
<header>.mvn/license/license-header.txt</header>
<includes>
<include>**/src/**/*.groovy</include>
<include>**/src/**/*.java</include>
<include>**/src/**/*.kt</include>
<include>**/src/**/*.properties</include>
<include>**/src/**/*.proto</include>
<include>**/*.xml</include>
</includes>
<excludes>
<exclude>.mvn/checkstyle/checkstyle.xml</exclude>
</excludes>
</licenseSet>
</licenseSets>
<mapping>
<java>SLASHSTAR_STYLE</java>
</mapping>
<properties>
<currentYear>2024</currentYear>
<inceptionYear>${project.inceptionYear}</inceptionYear>
</properties>
<strictCheck>true</strictCheck>
</configuration>

<executions>
<execution>
<id>validate-license-headers</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<!-- Checking style of code matches the Google code style. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>

<configuration>
<configLocation>.mvn/checkstyle/checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<includeResources>true</includeResources>
<sourceDirectories>${project.basedir}/src</sourceDirectories>
<suppressionsLocation>.mvn/checkstyle/suppressions.xml</suppressionsLocation>
<violationSeverity>info</violationSeverity>
</configuration>

<executions>
<execution>
<id>check-code-style</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>

<dependencies>
<dependency>
<!-- Force the usage of checkstyle v10 rather than v8.28 -->
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<!-- Java compiler config. -->
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -341,6 +360,12 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin.version}</version>
</plugin>

<plugin>
<!-- Runs integration tests. -->
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -408,6 +433,20 @@
<version>${maven-project-info-reports-plugin.version}</version>
</plugin>


<plugin>
<!-- Deployments and version incrementing. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<!-- These are run in the prepare phase already so don't run them twice -->
<arguments>-Dmaven.test.skip -Dinvoker.skip</arguments>
<goals>deploy</goals>
<releaseProfiles>gpg</releaseProfiles>
</configuration>
</plugin>

<plugin>
<!-- Generate the plugin site. -->
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -435,15 +474,17 @@
This block is needed to show @DisplayName and @ParameterizedTest
in reports with the provided names.
-->
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<statelessTestsetReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<disable>false</disable>
<version>3.0</version>
<usePhrasedFileName>false</usePhrasedFileName>
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
</statelessTestsetReporter>
<statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
<disable>false</disable>
<printStacktraceOnError>true</printStacktraceOnError>
<printStacktraceOnFailure>true</printStacktraceOnFailure>
Expand Down Expand Up @@ -483,6 +524,29 @@
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
</plugin>

<plugin>
<!-- Used in integration tests only. -->
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>

<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>

<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down Expand Up @@ -540,7 +604,6 @@
</plugins>
</reporting>


<profiles>
<profile>
<id>gpg</id>
Expand Down
5 changes: 2 additions & 3 deletions protobuf-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin-parent</artifactId>
<version>1.2.1-SNAPSHOT</version>
</parent>

<artifactId>protobuf-maven-plugin</artifactId>
<relativePath>../pom.xml</relativePath>
</parent> <artifactId>protobuf-maven-plugin</artifactId>
<name>Protobuf Maven Plugin</name>
<description>Generates compilable sources from Protobuf definitions.</description>
<packaging>maven-plugin</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>some-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>@project.groupId@</groupId>
<artifactId>protobuf-maven-plugin-parent</artifactId>
<version>@project.version@</version>
<relativePath>../../../../pom.xml</relativePath>
</parent>

<artifactId>gh-132-duplicate-maven-dependencies</artifactId>
<packaging>pom</packaging>

<modules>
Expand All @@ -35,14 +40,8 @@
</modules>

<properties>
<junit.version>5.10.1</junit.version>
<protobuf.version>4.26.1</protobuf.version>
<proto-google-common-protos.version>2.37.0</proto-google-common-protos.version>

<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
Expand All @@ -60,31 +59,12 @@
<version>${proto-google-common-protos.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>

<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
Expand Down
Loading

0 comments on commit e7a2153

Please sign in to comment.