Skip to content

Commit

Permalink
Apply spotless
Browse files Browse the repository at this point in the history
Pretty much same scheme as in Maven project:
* check runs in build and will fail it if not properly formatted
* mvn spotless:apply to format (or -P format)
  • Loading branch information
cstamas committed Feb 9, 2024
1 parent 0bb9c06 commit 94c9319
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 37 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
target/
.project
.classpath
.settings/
bin
.project
.settings
*.iml
.idea
out/
.DS_Store
133 changes: 99 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<version>53-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Takari</name>
<url>http://takari.io</url>
<description>Takari: The future of software delivery.</description>
<url>http://takari.io</url>

<licenses>
<license>
Expand Down Expand Up @@ -56,6 +56,13 @@
</developer>
</developers>

<scm>
<connection>scm:git:[email protected]:takari/takari-pom.git</connection>
<developerConnection>scm:git:[email protected]:takari/takari-pom.git</developerConnection>
<tag>HEAD</tag>
<url>http://github.com/takari/takari-pom</url>
</scm>

<distributionManagement>
<repository>
<id>sonatype.releases</id>
Expand Down Expand Up @@ -103,40 +110,7 @@
<maven.compiler.target>${takari.javaSourceVersion}</maven.compiler.target>
</properties>

<scm>
<connection>scm:git:[email protected]:takari/takari-pom.git</connection>
<developerConnection>scm:git:[email protected]:takari/takari-pom.git</developerConnection>
<url>http://github.com/takari/takari-pom</url>
<tag>HEAD</tag>
</scm>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.6.3,)</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- set versions/configuration of common plugins for reproducibility, ordered alphabetically -->
Expand Down Expand Up @@ -324,6 +298,45 @@
</mapping>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<java>
<!-- orders of used formatters are important MPOM-376 -->
<!-- eg. palantir override importOrder, so should be first -->
<palantirJavaFormat />
<removeUnusedImports />
<importOrder />
</java>
<pom>
<sortPom>
<expandEmptyElements>false</expandEmptyElements>
<!-- https://issues.apache.org/jira/browse/MRELEASE-1111 -->
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
</sortPom>
</pom>
<upToDateChecking>
<enabled>true</enabled>
</upToDateChecking>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-resources</artifactId>
<version>5</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>${spotless.action}</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
Expand Down Expand Up @@ -351,9 +364,61 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.6.3,)</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>format-check</id>
<activation>
<property>
<name>!format</name>
</property>
</activation>
<properties>
<spotless.action>check</spotless.action>
</properties>
</profile>
<profile>
<id>format</id>
<activation>
<property>
<name>format</name>
</property>
</activation>
<properties>
<spotless.action>apply</spotless.action>
</properties>
</profile>
<!-- START SNIPPET: release-profile -->
<profile>
<id>takari-release</id>
Expand Down

0 comments on commit 94c9319

Please sign in to comment.