Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Run checkstyle
# Checkstyle 13+ requires Java 21+.
on: [push, pull_request]
permissions: {}
jobs:
checkstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
submodules: true
persist-credentials: false
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: zulu
java-version: 24
- run: mvn checkstyle:check -B
75 changes: 18 additions & 57 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@
</execution>
</executions>
</plugin>
<!-- Checkstyle 13+ requires Java 21+. Run manually or via CI. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>checkstyle.xml</configLocation>
<violationSeverity>warning</violationSeverity>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>13.0.0</version>
</dependency>
</dependencies>
</plugin>
Comment on lines +132 to +148

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This plugin definition correctly configures Checkstyle for CI runs. However, it creates an inconsistency with the maven-checkstyle-plugin configuration used for reporting (mvn site) on lines 278-292. The reporting plugin will use a different (older) version of Checkstyle because it doesn't have this explicit dependency override. This can lead to different validation results between the CI check and the generated site report.

To ensure consistency and follow Maven best practices, I recommend managing common plugin configurations in a <pluginManagement> section. This would allow both the build and reporting executions to share the same version and dependencies, preventing discrepancies and improving maintainability.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
Expand Down Expand Up @@ -255,26 +273,6 @@
<japicmp.baselineVersion>4.0.0</japicmp.baselineVersion>
</properties>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.6.0</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
Expand Down Expand Up @@ -344,42 +342,5 @@
</plugins>
</build>
</profile>
<!-- Checkstyle 13+ requires Java 21+. -->
<profile>
<id>checkstyle-jdk21</id>
<activation>
<jdk>[21,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<consoleOutput>true</consoleOutput>
<configLocation>checkstyle.xml</configLocation>
<violationSeverity>warning</violationSeverity>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>13.0.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>checkstyle</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading