Skip to content

Commit 4c27f74

Browse files
Apply automatic Spotless formatting for Java and POM files (#92)
1 parent 3d9d90f commit 4c27f74

File tree

4 files changed

+97
-22
lines changed

4 files changed

+97
-22
lines changed

parent_toplevel/changes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
xsi:schemaLocation="http://maven.apache.org/changes/2.0.0 https://maven.apache.org/xsd/changes-2.0.0.xsd">
2525
<body>
2626

27-
<release version="2.1.4" date="not released">
27+
<release version="2.2.0" date="not released">
28+
<action type="add" dev="sseifert" issue="92">
29+
Apply automatic Spotless formatting for Java and POM files.
30+
</action>
2831
<action type="update" dev="sseifert">
2932
Update global-parent dependency to 76.
3033
</action>

parent_toplevel/pom.xml

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
limitations under the License.
1919
#L%
2020
-->
21-
2221
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2322
<modelVersion>4.0.0</modelVersion>
2423

@@ -31,7 +30,7 @@
3130

3231
<groupId>io.wcm.devops</groupId>
3332
<artifactId>io.wcm.devops.parent_toplevel</artifactId>
34-
<version>2.1.3-SNAPSHOT</version>
33+
<version>2.2.0-SNAPSHOT</version>
3534
<packaging>pom</packaging>
3635

3736
<name>Toplevel Parent</name>
@@ -41,8 +40,8 @@
4140
<scm>
4241
<connection>scm:git:https://github.com/wcm-io-devops/devops-tooling.git</connection>
4342
<developerConnection>scm:git:https://github.com/wcm-io-devops/devops-tooling.git</developerConnection>
44-
<url>https://github.com/wcm-io-devops/devops-tooling</url>
4543
<tag>HEAD</tag>
44+
<url>https://github.com/wcm-io-devops/devops-tooling</url>
4645
</scm>
4746

4847
<inceptionYear>2015</inceptionYear>
@@ -185,10 +184,10 @@
185184
<artifactId>license-maven-plugin</artifactId>
186185
<executions>
187186
<execution>
188-
<phase>validate</phase>
189187
<goals>
190188
<goal>check-file-header</goal>
191189
</goals>
190+
<phase>validate</phase>
192191
</execution>
193192
</executions>
194193
</plugin>
@@ -211,18 +210,18 @@
211210
<plugin>
212211
<groupId>org.apache.maven.plugins</groupId>
213212
<artifactId>maven-site-plugin</artifactId>
213+
<configuration>
214+
<generateReports>true</generateReports>
215+
<inputEncoding>UTF-8</inputEncoding>
216+
<outputEncoding>UTF-8</outputEncoding>
217+
</configuration>
214218
<dependencies>
215219
<dependency>
216220
<groupId>io.wcm.maven.skins</groupId>
217221
<artifactId>reflow-velocity-tools</artifactId>
218222
<version>1.1.0</version>
219223
</dependency>
220224
</dependencies>
221-
<configuration>
222-
<generateReports>true</generateReports>
223-
<inputEncoding>UTF-8</inputEncoding>
224-
<outputEncoding>UTF-8</outputEncoding>
225-
</configuration>
226225
<executions>
227226
<execution>
228227
<id>attach-descriptor</id>
@@ -233,6 +232,56 @@
233232
</executions>
234233
</plugin>
235234

235+
<plugin>
236+
<groupId>com.diffplug.spotless</groupId>
237+
<artifactId>spotless-maven-plugin</artifactId>
238+
<version>3.3.0</version>
239+
<configuration>
240+
<java>
241+
<eclipse>
242+
<file>global-build-tools/eclipse/java-formatter.xml</file>
243+
</eclipse>
244+
<removeUnusedImports />
245+
<licenseHeader>
246+
<file>global-build-tools/spotless/header-java.txt</file>
247+
</licenseHeader>
248+
</java>
249+
<!-- accept all endings to support validations on top of source archives -->
250+
<lineEndings>PRESERVE</lineEndings>
251+
<pom>
252+
<licenseHeader>
253+
<file>global-build-tools/spotless/header-xml.txt</file>
254+
<delimiter>&lt;project</delimiter>
255+
</licenseHeader>
256+
<sortPom>
257+
<sortOrderFile>global-build-tools/spotless/sortpom.xml</sortOrderFile>
258+
<nrOfIndentSpace>2</nrOfIndentSpace>
259+
<expandEmptyElements>false</expandEmptyElements>
260+
<!-- https://issues.apache.org/jira/browse/MRELEASE-1111 -->
261+
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
262+
</sortPom>
263+
</pom>
264+
<upToDateChecking>
265+
<enabled>true</enabled>
266+
</upToDateChecking>
267+
</configuration>
268+
<dependencies>
269+
<dependency>
270+
<groupId>io.wcm.maven</groupId>
271+
<artifactId>io.wcm.maven.global-build-tools</artifactId>
272+
<version>36-SNAPSHOT</version>
273+
</dependency>
274+
</dependencies>
275+
<executions>
276+
<execution>
277+
<goals>
278+
<goal>${spotless.action}</goal>
279+
</goals>
280+
<phase>process-sources</phase>
281+
</execution>
282+
</executions>
283+
</plugin>
284+
236285
<!-- Workaround for change of report filename changes-report.html to changes.html with maven-changes-plugin 3.x
237286
We have a lot of links out there from GitHub releases, and we cannot configure a server-side redirect for GitHub pages.
238287
So, create a file that redirects to the new report name here. -->
@@ -257,10 +306,10 @@
257306
<executions>
258307
<execution>
259308
<id>generate-file</id>
260-
<phase>site</phase>
261309
<goals>
262310
<goal>write</goal>
263311
</goals>
312+
<phase>site</phase>
264313
</execution>
265314
</executions>
266315
</plugin>
@@ -375,6 +424,7 @@
375424
</reporting>
376425

377426
<profiles>
427+
378428
<!-- profile used for building releases and deployment to sonatype/maven central -->
379429
<profile>
380430
<id>release-profile</id>
@@ -394,19 +444,19 @@
394444
<executions>
395445
<execution>
396446
<id>sign-artifacts</id>
397-
<phase>verify</phase>
398447
<goals>
399448
<goal>sign</goal>
400449
</goals>
450+
<phase>verify</phase>
401451
</execution>
402452
</executions>
403453
</plugin>
404454
<!-- configure staging process at sonatype.-->
405455
<plugin>
406456
<groupId>org.sonatype.central</groupId>
407457
<artifactId>central-publishing-maven-plugin</artifactId>
408-
<inherited>true</inherited>
409458
<extensions>true</extensions>
459+
<inherited>true</inherited>
410460
<configuration>
411461
<publishingServerId>sonatype-central</publishingServerId>
412462
<deploymentName>${project.artifactId} ${project.version}</deploymentName>
@@ -415,6 +465,32 @@
415465
</plugins>
416466
</build>
417467
</profile>
468+
469+
<!-- only check formatting with spotless by default in CI builds -->
470+
<profile>
471+
<id>spotless-format-check</id>
472+
<activation>
473+
<property>
474+
<name>env.CI</name>
475+
</property>
476+
</activation>
477+
<properties>
478+
<spotless.action>check</spotless.action>
479+
</properties>
480+
</profile>
481+
<!-- reformat during build with spotless with -Pformat -->
482+
<profile>
483+
<id>format</id>
484+
<activation>
485+
<property>
486+
<name>!env.CI</name>
487+
</property>
488+
</activation>
489+
<properties>
490+
<spotless.action>apply</spotless.action>
491+
</properties>
492+
</profile>
493+
418494
</profiles>
419495

420496
<distributionManagement>

pom.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
limitations under the License.
1919
#L%
2020
-->
21-
22-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2422
<modelVersion>4.0.0</modelVersion>
2523

2624
<parent>
2725
<groupId>io.wcm.devops</groupId>
2826
<artifactId>io.wcm.devops.parent_toplevel</artifactId>
29-
<version>2.1.2</version>
27+
<version>2.2.0-SNAPSHOT</version>
3028
<relativePath>parent_toplevel/pom.xml</relativePath>
3129
</parent>
3230

public_site/pom.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
limitations under the License.
1919
#L%
2020
-->
21-
22-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2422
<modelVersion>4.0.0</modelVersion>
2523

2624
<parent>
2725
<groupId>io.wcm.devops</groupId>
2826
<artifactId>io.wcm.devops.parent_toplevel</artifactId>
29-
<version>2.1.2</version>
27+
<version>2.2.0-SNAPSHOT</version>
3028
<relativePath>../parent_toplevel/pom.xml</relativePath>
3129
</parent>
3230

@@ -42,8 +40,8 @@
4240
<scm>
4341
<connection>scm:git:https://github.com/wcm-io-devops/devops-tooling.git</connection>
4442
<developerConnection>scm:git:https://github.com/wcm-io-devops/devops-tooling.git</developerConnection>
45-
<url>https://github.com/wcm-io-devops/devops-tooling</url>
4643
<tag>HEAD</tag>
44+
<url>https://github.com/wcm-io-devops/devops-tooling</url>
4745
</scm>
4846

4947
<ciManagement>

0 commit comments

Comments
 (0)