Skip to content

Commit 42b25f7

Browse files
committed
Merge ../spotless into type-annotation-on-class-test
2 parents 26f8f59 + d201491 commit 42b25f7

File tree

12 files changed

+75
-24
lines changed

12 files changed

+75
-24
lines changed

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
repositories {
2+
mavenCentral()
3+
}
14
apply from: rootProject.file('gradle/java-publish.gradle')
25
apply from: rootProject.file('gradle/changelog.gradle')
36
allprojects {
47
apply from: rootProject.file('gradle/spotless.gradle')
58
}
69
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
710

8-
repositories {
9-
mavenCentral()
10-
}
1111
spotless {
1212
groovyGradle {
1313
target '*.gradle', 'gradle/*.gradle'

gradle.properties

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ artifactIdGradle=spotless-plugin-gradle
1717

1818
# Build requirements
1919
VER_JAVA=1.8
20-
VER_SPOTBUGS=4.5.0
20+
VER_SPOTBUGS=4.7.2
2121
VER_JSR_305=3.0.2
2222

2323
# Dependencies provided by Spotless plugin
@@ -26,12 +26,12 @@ VER_SLF4J=[1.6,2.0[
2626
# Used in multiple places
2727
VER_DURIAN=1.2.0
2828
VER_JGIT=5.13.1.202206130422-r
29-
VER_JUNIT=5.9.0
29+
VER_JUNIT=5.9.1
3030
VER_ASSERTJ=3.23.1
31-
VER_MOCKITO=3.12.4
31+
VER_MOCKITO=4.8.0
3232

3333
# Used for Maven Plugin
3434
VER_MAVEN_API=3.0
35-
VER_ECLIPSE_AETHER=0.9.1.v20140329
35+
VER_ECLIPSE_AETHER=1.1.0
3636
VER_MUSTACHE=0.9.10
3737
VER_PLEXUS_RESOURCES=1.2.0

plugin-gradle/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apply from: rootProject.file('gradle/changelog.gradle')
22
ext.artifactId = project.artifactIdGradle
33
version = spotlessChangelog.versionNext
4+
apply plugin: 'java-library'
45
apply from: rootProject.file('gradle/java-setup.gradle')
56
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
67

7-
apply plugin: 'java-library'
88
apply plugin: 'com.gradle.plugin-publish'
99
apply plugin: 'java-gradle-plugin'
1010

plugin-maven/CHANGES.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
44

55
## [Unreleased]
66

7+
## [2.27.2] - 2022-10-10
8+
### Fixed
9+
* `replace` and `replaceRegex` steps now allow you to replace something with an empty string, previously this would generate a null pointer exception. (fixes [#1359](https://github.com/diffplug/spotless/issues/1359))
10+
11+
## [2.27.1] - 2022-09-28
12+
### Fixed
13+
* `skip` config key should work again now. ([#1353](https://github.com/diffplug/spotless/pull/1353) fixes [#1227](https://github.com/diffplug/spotless/issues/1227) and [#491](https://github.com/diffplug/spotless/issues/491))
14+
15+
## [2.27.0] - 2022-09-19
16+
### Added
17+
* Support for `editorConfigOverride` in `ktlint`, `plugin-maven`. ([#1335](https://github.com/diffplug/spotless/pull/1335) fixes [#1334](https://github.com/diffplug/spotless/issues/1334))
18+
719
## [2.26.0] - 2022-09-14
820
### Added
921
* `formatAnnotations` step to correct formatting of Java type annotations. It puts type annotations on the same line as the type that they qualify. Run it after a Java formatting step, such as `googleJavaFormat`. ([#1275](https://github.com/diffplug/spotless/pull/1275))

plugin-maven/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ output = [
1212
].join('\n');
1313
-->
1414
[![Maven central](https://img.shields.io/badge/mavencentral-com.diffplug.spotless%3Aspotless--maven--plugin-blue.svg)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.diffplug.spotless%22%20AND%20a%3A%22spotless-maven-plugin%22)
15-
[![Javadoc](https://img.shields.io/badge/javadoc-yes-blue.svg)](https://javadoc.io/doc/com.diffplug.spotless/spotless-maven-plugin/2.26.0/index.html)
16-
[![Changelog](https://img.shields.io/badge/changelog-2.26.0-brightgreen.svg)](CHANGES.md)
15+
[![Javadoc](https://img.shields.io/badge/javadoc-yes-blue.svg)](https://javadoc.io/doc/com.diffplug.spotless/spotless-maven-plugin/2.27.2/index.html)
16+
[![Changelog](https://img.shields.io/badge/changelog-2.27.2-brightgreen.svg)](CHANGES.md)
1717

1818
[![Circle CI](https://circleci.com/gh/diffplug/spotless/tree/main.svg?style=shield)](https://circleci.com/gh/diffplug/spotless/tree/main)
1919
[![Live chat](https://img.shields.io/badge/gitter-chat-brightgreen.svg)](https://gitter.im/diffplug/spotless)
@@ -359,6 +359,10 @@ Groovy-Eclipse formatting errors/warnings lead per default to a build failure. T
359359
```xml
360360
<ktlint>
361361
<version>0.43.2</version> <!-- optional -->
362+
<editorConfigOverride> <!-- optional -->
363+
<ij_kotlin_allow_trailing_comma>true</ij_kotlin_allow_trailing_comma>
364+
<ij_kotlin_allow_trailing_comma_on_call_site>true</ij_kotlin_allow_trailing_comma_on_call_site>
365+
</editorConfigOverride>
362366
</ktlint>
363367
```
364368

plugin-maven/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ buildscript {
55
plugins {
66
id 'cz.malohlava.visteg' version '1.0.5' // https://github.com/mmalohlava/gradle-visteg
77
}
8+
repositories { mavenCentral() }
89
apply from: rootProject.file('gradle/changelog.gradle')
910
apply from: rootProject.file('gradle/spotless-freshmark.gradle')
1011

plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public abstract class AbstractSpotlessMojo extends AbstractMojo {
9191
@Parameter(defaultValue = "${mojoExecution.goal}", required = true, readonly = true)
9292
private String goal;
9393

94+
@Parameter(defaultValue = "false")
95+
private boolean skip;
96+
9497
@Parameter(property = "spotless.apply.skip", defaultValue = "false")
9598
private boolean applySkip;
9699

@@ -200,6 +203,10 @@ public final void execute() throws MojoExecutionException {
200203
}
201204

202205
private boolean shouldSkip() {
206+
if (skip) {
207+
return true;
208+
}
209+
203210
switch (goal) {
204211
case GOAL_CHECK:
205212
return checkSkip;
@@ -208,6 +215,7 @@ private boolean shouldSkip() {
208215
default:
209216
break;
210217
}
218+
211219
return false;
212220
}
213221

plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Replace.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,10 +35,12 @@ public class Replace implements FormatterStepFactory {
3535

3636
@Override
3737
public FormatterStep newFormatterStep(FormatterStepConfig config) {
38-
if (name == null || search == null || replacement == null) {
39-
throw new IllegalArgumentException("Must specify 'name', 'search' and 'replacement'.");
38+
if (name == null || search == null) {
39+
throw new IllegalArgumentException("Must specify 'name' and 'search'.");
4040
}
41-
42-
return ReplaceStep.create(name, search, replacement);
41+
// Use empty string if replacement is not provided. In pom.xml there is no way to specify
42+
// an empty string as a property value as maven will always trim the value and if it is
43+
// empty, maven will consider the property as not provided.
44+
return ReplaceStep.create(name, search, replacement != null ? replacement : "");
4345
}
4446
}

plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/ReplaceRegex.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,10 +35,12 @@ public class ReplaceRegex implements FormatterStepFactory {
3535

3636
@Override
3737
public FormatterStep newFormatterStep(FormatterStepConfig config) {
38-
if (name == null || searchRegex == null || replacement == null) {
39-
throw new IllegalArgumentException("Must specify 'name', 'searchRegex' and 'replacement'.");
38+
if (name == null || searchRegex == null) {
39+
throw new IllegalArgumentException("Must specify 'name' and 'searchRegex'.");
4040
}
41-
42-
return ReplaceRegexStep.create(name, searchRegex, replacement);
41+
// Use empty string if replacement is not provided. In pom.xml there is no way to specify
42+
// an empty string as a property value as maven will always trim the value and if it is
43+
// empty, maven will consider the property as not provided.
44+
return ReplaceRegexStep.create(name, searchRegex, replacement != null ? replacement : "");
4345
}
4446
}

plugin-maven/src/main/java/com/diffplug/spotless/maven/kotlin/Ktlint.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,10 @@
1515
*/
1616
package com.diffplug.spotless.maven.kotlin;
1717

18+
import java.util.Collections;
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
1822
import org.apache.maven.plugins.annotations.Parameter;
1923

2024
import com.diffplug.spotless.FormatterStep;
@@ -27,9 +31,17 @@ public class Ktlint implements FormatterStepFactory {
2731
@Parameter
2832
private String version;
2933

34+
@Parameter
35+
private Map<String, Object> editorConfigOverride;
36+
3037
@Override
3138
public FormatterStep newFormatterStep(FormatterStepConfig config) {
3239
String ktlintVersion = version != null ? version : KtLintStep.defaultVersion();
33-
return KtLintStep.create(ktlintVersion, config.getProvisioner());
40+
41+
if (editorConfigOverride == null) {
42+
editorConfigOverride = new HashMap<>();
43+
}
44+
45+
return KtLintStep.create(ktlintVersion, config.getProvisioner(), false, Collections.emptyMap(), editorConfigOverride);
3446
}
3547
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtlintTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,14 @@ void testKtlint() throws Exception {
2929
mavenRunner().withArguments("spotless:apply").runNoError();
3030
assertFile(path).sameAsResource("kotlin/ktlint/basic.clean");
3131
}
32+
33+
@Test
34+
void testKtlintEditorConfigOverride() throws Exception {
35+
writePomWithKotlinSteps("<ktlint><editorConfigOverride><ij_kotlin_allow_trailing_comma>true</ij_kotlin_allow_trailing_comma><ij_kotlin_allow_trailing_comma_on_call_site>true</ij_kotlin_allow_trailing_comma_on_call_site></editorConfigOverride></ktlint>");
36+
37+
String path = "src/main/kotlin/Main.kt";
38+
setFile(path).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty");
39+
mavenRunner().withArguments("spotless:apply").runNoError();
40+
assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.clean");
41+
}
3242
}

settings.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
pluginManagement {
22
plugins {
3-
id 'com.diffplug.spotless' version '6.5.0'
3+
id 'com.diffplug.spotless' version '6.11.0'
44
// https://plugins.gradle.org/plugin/com.gradle.plugin-publish
55
id 'com.gradle.plugin-publish' version '1.0.0'
66
// https://github.com/gradle-nexus/publish-plugin/releases
77
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
88
// https://github.com/spotbugs/spotbugs-gradle-plugin/releases
99
id 'com.github.spotbugs' version '5.0.12'
1010
// https://github.com/diffplug/spotless-changelog
11-
id 'com.diffplug.spotless-changelog' version '2.3.2'
11+
id 'com.diffplug.spotless-changelog' version '2.4.0'
1212
// https://github.com/diffplug/goomph/blob/main/CHANGES.md
1313
id 'com.diffplug.p2.asmaven' version '3.27.0' // DO NOT UPDATE, see https://github.com/diffplug/spotless/pull/874
1414
// https://github.com/gradle/test-retry-gradle-plugin/releases

0 commit comments

Comments
 (0)