Skip to content

Commit

Permalink
Add eclipse formatter and import order, rel #297 (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
sschnabe committed Dec 4, 2024
1 parent f1ce00b commit faed4f1
Show file tree
Hide file tree
Showing 5 changed files with 502 additions and 3 deletions.
94 changes: 94 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
<version.org.codehaus.mojo.tidy>1.3.0</version.org.codehaus.mojo.tidy>
<version.org.codehaus.mojo.versions>2.18.0</version.org.codehaus.mojo.versions>
<version.org.sonatype.plugins.nexus-staging>1.7.0</version.org.sonatype.plugins.nexus-staging>
<version.net.revelc.code.formatter>2.24.1</version.net.revelc.code.formatter>
<version.net.revelc.code.impsort>1.12.0</version.net.revelc.code.impsort>

<version.org.junit.jupiter>5.11.3</version.org.junit.jupiter>
<version.org.slf4j>2.0.16</version.org.slf4j>
Expand Down Expand Up @@ -282,6 +284,24 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>${version.net.revelc.code.formatter}</version>
<configuration>
<configFile>${project.basedir}/src/main/eclipse/formatter.xml</configFile>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>${version.net.revelc.code.impsort}</version>
<configuration>
<groups>java.,javax.,org.,com.</groups>
<removeUnused>true</removeUnused>
<treatSamePackageAsUnused>true</treatSamePackageAsUnused>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -342,6 +362,54 @@
</build>

<profiles>
<profile>
<id>format</id>
<build>
<plugins>

<!-- fail if any pom is dirty -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tidy-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>pom</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- fail if java is misformatted -->
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>sort</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>
<profile>
<id>check</id>
<activation>
Expand All @@ -366,6 +434,32 @@
</executions>
</plugin>

<!-- fail if java is misformatted -->
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>
Expand Down
Loading

0 comments on commit faed4f1

Please sign in to comment.