You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2022/09/22 19:14:40 UTC
[db-jdo] branch main updated: Maven plugin using Google Java Formatter (#57)
This is an automated email from the ASF dual-hosted git repository.
mbo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/db-jdo.git
The following commit(s) were added to refs/heads/main by this push:
new 594de1fe Maven plugin using Google Java Formatter (#57)
594de1fe is described below
commit 594de1fedda4a685d94b59d2adb859708fb808ba
Author: Michael Bouschen <mb...@apache.org>
AuthorDate: Thu Sep 22 21:14:35 2022 +0200
Maven plugin using Google Java Formatter (#57)
JDO-818: maven plugin to check and format Java code using Google Java Formatter
---
README.md | 15 ++++++++
parent-pom/pom.xml | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 214bf885..e904b2a3 100644
--- a/README.md
+++ b/README.md
@@ -162,3 +162,18 @@ Please note, the tck enables the profile `jdori` per default and this default is
You can pass different compiler arguments using the -D option:
mvn -Pwarnings,jdori -DcompilerArgument=-Xlint:all clean install
+
+### Formatting
+
+The JDO project uses the google-java-format for checking and reformatting the Java code to comply with
+Google Java Style [Google Java Style](https://google.github.io/styleguide/javaguide.html).
+
+There are two profiles to support code formatting using the maven fmt-maven-plugin.
+
+* `verify-format` checks the formatting of the project's Java files. It prints the list of the files that are not compliant.
+
+ mvn -Pverify-format clean compile
+
+* `format` reformats the project's Java files.
+
+ mvn -Pformat clean compile
diff --git a/parent-pom/pom.xml b/parent-pom/pom.xml
index f6f61ec0..3197f6c2 100644
--- a/parent-pom/pom.xml
+++ b/parent-pom/pom.xml
@@ -284,6 +284,20 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.0</version>
</plugin>
+ <plugin>
+ <artifactId>org.apache.rat</artifactId>
+ <version>0.14</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify.fmt</groupId>
+ <artifactId>fmt-maven-plugin</artifactId>
+ <version>2.19</version>
+ </plugin>
</plugins>
</pluginManagement>
@@ -310,7 +324,6 @@
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
- <version>0.14</version>
</plugin>
</plugins>
</build>
@@ -349,5 +362,93 @@
<compilerArgument>-Xlint:all,-rawtypes</compilerArgument>
</properties>
</profile>
+ <profile>
+ <!-- Profile to format the sources using the Google Java formatter -->
+ <id>format</id>
+ <build>
+ <plugins>
+ <plugin>
+ <!-- This plugin makes sure to run the profile with a JDK 11 or above -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-versions</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>[11,)</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify.fmt</groupId>
+ <artifactId>fmt-maven-plugin</artifactId>
+ <configuration>
+ <verbose>true</verbose>
+ <skipSortingImports>false</skipSortingImports>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <!-- Profile to format the sources using the Google Java formatter -->
+ <id>verify-format</id>
+ <build>
+ <plugins>
+ <plugin>
+ <!-- This plugin makes sure to run the profile with a JDK 11 or above -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-versions</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>[11,)</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify.fmt</groupId>
+ <artifactId>fmt-maven-plugin</artifactId>
+ <configuration>
+ <displayLimit>1000</displayLimit>
+ <verbose>true</verbose>
+ <failOnError>false</failOnError>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>