Skip to content

Commit

Permalink
Apply spotless (#17)
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)

Fixes #13

Due spotless plugin (does not run on Java8) the "build time Java requirement" raises to Java 11, but IMHO this is not a problem as we already build most of the projects with it.

---

Applying this parent in project will need 3 steps:
* PR to change parent version (build will fail due formatting)
* subsequent commit where developer runs `mvn spotless:apply` and pushes (build will pass)
* subsequent commit to repository root into file `.git-blame-ignore-revs` with commit hash from 2nd commit
  • Loading branch information
cstamas authored Feb 9, 2024
1 parent 7f94abb commit 0674a89
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 66 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ name: Verify

on:
push:
branches:
- master
pull_request:

jobs:
build:
name: Verify
uses: takari/takari-gh-actions/.github/workflows/ci.yml@v2
uses: takari/takari-gh-actions/.github/workflows/ci.yml@v3
with:
jdk-matrix: '[ 8 ]' # for POM one JDK is enough
jdk-matrix: '[ 11 ]' # for POM one JDK is enough
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
188 changes: 127 additions & 61 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2014 Takari, Inc.
Copyright (c) 2016 Takari, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
Expand All @@ -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 @@ -290,40 +264,77 @@
<configuration>
<aggregate>true</aggregate>
<strictCheck>true</strictCheck>
<header>${takari.licenseHeader}</header>
<useDefaultExcludes>false</useDefaultExcludes>
<includes>
<include>**/pom.xml</include>
<include>**/*.xml</include>
<include>**/*.xsd</include>
<include>**/*.xjb</include>
<include>**/*.mdo</include>
<include>**/*.properties</include>
<include>**/*.java</include>
<include>**/*.groovy</include>
<include>**/*.scala</include>
<include>**/*.aj</include>
<include>**/*.js</include>
<include>**/*.css</include>
</includes>
<excludes>
<exclude>**/target/**</exclude>
<exclude>**/conf/**</exclude>
<exclude>**/.*</exclude>
<exclude>**/pkg/**</exclude>
<exclude>**/.idea/**</exclude>
<exclude>**/release.properties</exclude>
<exclude>**/pom.xml.releaseBackup</exclude>
<exclude>release.sh</exclude>
<exclude>**/src/test/**</exclude>
</excludes>
<licenseSets>
<licenseSet>
<header>${takari.licenseHeader}</header>
<includes>
<include>**/pom.xml</include>
<include>**/*.xml</include>
<include>**/*.xsd</include>
<include>**/*.xjb</include>
<include>**/*.mdo</include>
<include>**/*.properties</include>
<include>**/*.java</include>
<include>**/*.groovy</include>
<include>**/*.scala</include>
<include>**/*.aj</include>
<include>**/*.js</include>
<include>**/*.css</include>
</includes>
<excludes>
<exclude>.mvn/wrapper/**</exclude>
<exclude>**/target/**</exclude>
<exclude>**/conf/**</exclude>
<exclude>**/.*</exclude>
<exclude>**/pkg/**</exclude>
<exclude>**/.idea/**</exclude>
<exclude>**/release.properties</exclude>
<exclude>**/pom.xml.releaseBackup</exclude>
<exclude>release.sh</exclude>
<exclude>**/src/test/**</exclude>
</excludes>
</licenseSet>
</licenseSets>
<mapping>
<scala>JAVADOC_STYLE</scala>
<xjb>XML_STYLE</xjb>
<mdo>XML_STYLE</mdo>
</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>
<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 +362,64 @@
</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>
<requireJavaVersion>
<version>[11,)</version>
</requireJavaVersion>
<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 0674a89

Please sign in to comment.