Skip to content

Commit f8198b5

Browse files
authored
Merge pull request #630 from diffplug/remove-deprecated-break-maven
Remove deprecated features from plugin-maven, and let plugin-gradle zombie-along
2 parents 989abbe + 41a0d96 commit f8198b5

File tree

20 files changed

+49
-316
lines changed

20 files changed

+49
-316
lines changed

CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
2020
* This change allows the maven plugin to cache classloaders across subprojects when loading config resources from the classpath (fixes [#559](https://github.com/diffplug/spotless/issues/559)).
2121
* This change also allows the gradle plugin to work with the remote buildcache (fixes [#280](https://github.com/diffplug/spotless/issues/280)).
2222
* **BREAKING** Heavy refactor of the `LicenseHeaderStep` public API. Doesn't change internal behavior, but makes implementation of the gradle and maven plugins much easier. ([#628](https://github.com/diffplug/spotless/pull/628))
23-
* **BREAKING** Removed all deprecated methods and classes.
23+
* **BREAKING** Removed all deprecated methods and classes from `lib` and `lib-extra`.
2424
* [#629](https://github.com/diffplug/spotless/pull/629) removes the code which wasn't being used in plugin-gradle or plugin-maven.
25+
* [#630](https://github.com/diffplug/spotless/pull/630) moves the code which was still being used in deprecated parts of plugin-gradle into `.deprecated` package in `plugin-gradle`, which allows us to break `lib` without a breaking change in `plugin-gradle`.
2526

2627
## [1.34.1] - 2020-06-17
2728
### Changed

lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,6 @@ public static String defaultVersion() {
5656
return DEFAULT_VERSION;
5757
}
5858

59-
/**
60-
* Provides default configuration for CSSformatter.
61-
* Method is deprecated. Use {@link EclipseWtpFormatterStep#createBuilder(Provisioner)} instead.
62-
*/
63-
@Deprecated
64-
public static EclipseBasedStepBuilder createCssBuilder(Provisioner provisioner) {
65-
return new EclipseBasedStepBuilder(NAME, " - css", provisioner, state -> applyWithoutFile("EclipseCssFormatterStepImpl", state));
66-
}
67-
68-
/**
69-
* Provides default configuration for XML formatter.
70-
* Method is deprecated. Use {@link EclipseWtpFormatterStep#createBuilder(Provisioner)} instead.
71-
*/
72-
@Deprecated
73-
public static EclipseBasedStepBuilder createXmlBuilder(Provisioner provisioner) {
74-
return XML.createBuilder(provisioner);
75-
}
76-
7759
private static FormatterFunc applyWithoutFile(String className, EclipseBasedStepBuilder.State state) throws Exception {
7860
Class<?> formatterClazz = state.loadClass(FORMATTER_PACKAGE + className);
7961
Object formatter = formatterClazz.getConstructor(Properties.class).newInstance(state.getPreferences());

lib/src/main/java/com/diffplug/spotless/css/package-info.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/src/main/java/com/diffplug/spotless/xml/package-info.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

plugin-gradle/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
88
### Added
99
* Full support for the Gradle buildcache - previously only supported local, now supports remote too. Fixes [#566](https://github.com/diffplug/spotless/issues/566) and [#280](https://github.com/diffplug/spotless/issues/280), via changes in [#621](https://github.com/diffplug/spotless/pull/621) and [#571](https://github.com/diffplug/spotless/pull/571).
1010
* `prettier` will now autodetect the parser (and formatter) to use based on the filename, unless you override this using `config()` or `configFile()` with the option `parser` or `filepath`. ([#620](https://github.com/diffplug/spotless/pull/620))
11+
* (user-invisible) moved the deprecated lib code which was only being used in deprecated parts of `plugin-gradle` into the `.libdeprecated` package. ([#630](https://github.com/diffplug/spotless/pull/630))
1112
### Fixed
1213
* LineEndings.GIT_ATTRIBUTES is now a bit more efficient, and paves the way for remote build cache support in Gradle. ([#621](https://github.com/diffplug/spotless/pull/621))
1314
* `ratchetFrom` now ratchets from the merge base of `HEAD` and the specified branch. This fixes the surprising behavior when a remote branch advanced ([#631](https://github.com/diffplug/spotless/pull/631) fixes [#627](https://github.com/diffplug/spotless/issues/627)).

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717

1818
import static com.diffplug.gradle.spotless.PluginGradlePreconditions.requireElementsNonNull;
1919

20+
import java.lang.reflect.InvocationTargetException;
21+
import java.lang.reflect.Method;
22+
import java.util.Properties;
23+
2024
import org.gradle.api.Project;
2125

22-
import com.diffplug.spotless.css.CssDefaults;
26+
import com.diffplug.gradle.spotless.libdeprecated.CssDefaults;
27+
import com.diffplug.spotless.FormatterFunc;
28+
import com.diffplug.spotless.Provisioner;
2329
import com.diffplug.spotless.extra.EclipseBasedStepBuilder;
2430
import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep;
2531

@@ -42,6 +48,28 @@ public EclipseConfig eclipse(String version) {
4248
return new EclipseConfig(version);
4349
}
4450

51+
private static EclipseBasedStepBuilder createCssBuilder(Provisioner provisioner) {
52+
return new EclipseBasedStepBuilder(NAME, " - css", provisioner, state -> applyWithoutFile("EclipseCssFormatterStepImpl", state));
53+
}
54+
55+
private static FormatterFunc applyWithoutFile(String className, EclipseBasedStepBuilder.State state) throws Exception {
56+
Class<?> formatterClazz = state.loadClass(FORMATTER_PACKAGE + className);
57+
Object formatter = formatterClazz.getConstructor(Properties.class).newInstance(state.getPreferences());
58+
Method method = formatterClazz.getMethod(FORMATTER_METHOD, String.class);
59+
return input -> {
60+
try {
61+
return (String) method.invoke(formatter, input);
62+
} catch (InvocationTargetException exceptionWrapper) {
63+
Throwable throwable = exceptionWrapper.getTargetException();
64+
Exception exception = (throwable instanceof Exception) ? (Exception) throwable : null;
65+
throw (null == exception) ? exceptionWrapper : exception;
66+
}
67+
};
68+
}
69+
70+
private static final String FORMATTER_PACKAGE = "com.diffplug.spotless.extra.eclipse.wtp.";
71+
private static final String FORMATTER_METHOD = "format";
72+
4573
/**
4674
* The CSS Eclipse configuration is deprecated. Use the {@link FormatExtension.EclipseWtpConfig} instead.
4775
*/
@@ -50,7 +78,7 @@ public class EclipseConfig {
5078
private final EclipseBasedStepBuilder builder;
5179

5280
EclipseConfig(String version) {
53-
builder = EclipseWtpFormatterStep.createCssBuilder(provisioner());
81+
builder = createCssBuilder(provisioner());
5482
builder.setVersion(version);
5583
addStep(builder.build());
5684
}

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
import org.gradle.api.Project;
2121

22+
import com.diffplug.gradle.spotless.libdeprecated.XmlDefaults;
2223
import com.diffplug.spotless.extra.EclipseBasedStepBuilder;
2324
import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep;
24-
import com.diffplug.spotless.xml.XmlDefaults;
2525

2626
/**
2727
* The XML extension is deprecated. Use the generic {@link FormatExtension} instead.
@@ -46,7 +46,7 @@ public class EclipseConfig {
4646
private final EclipseBasedStepBuilder builder;
4747

4848
EclipseConfig(String version) {
49-
builder = EclipseWtpFormatterStep.createXmlBuilder(provisioner());
49+
builder = EclipseWtpFormatterStep.XML.createBuilder(provisioner());
5050
builder.setVersion(version);
5151
addStep(builder.build());
5252
}

lib/src/main/java/com/diffplug/spotless/css/CssDefaults.java renamed to plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaults.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2020 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.
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.diffplug.spotless.css;
16+
package com.diffplug.gradle.spotless.libdeprecated;
1717

1818
import java.util.Arrays;
1919
import java.util.Collections;

lib/src/main/java/com/diffplug/spotless/xml/XmlDefaults.java renamed to plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaults.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2020 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.
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.diffplug.spotless.xml;
16+
package com.diffplug.gradle.spotless.libdeprecated;
1717

1818
import java.util.Arrays;
1919
import java.util.Collections;

testlib/src/test/java/com/diffplug/spotless/css/CssDefaultsTest.java renamed to plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaultsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.diffplug.spotless.css;
16+
package com.diffplug.gradle.spotless.libdeprecated;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
1919

testlib/src/test/java/com/diffplug/spotless/xml/XmlDefaultsTest.java renamed to plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaultsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.diffplug.spotless.xml;
16+
package com.diffplug.gradle.spotless.libdeprecated;
1717

1818
import static org.assertj.core.api.Assertions.assertThat;
1919

plugin-maven/CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
88
* Huge speed improvement for multi-module projects thanks to improved cross-project classloader caching ([#571](https://github.com/diffplug/spotless/pull/571), fixes [#559](https://github.com/diffplug/spotless/issues/559)).
99
* If you specify `-DspotlessSetLicenseHeaderYearsFromGitHistory=true`, Spotless will perform an expensive search through git history to determine the oldest and newest commits for each file, and uses that to determine license header years. ([#626](https://github.com/diffplug/spotless/pull/626))
1010
* `prettier` will now autodetect the parser (and formatter) to use based on the filename, unless you override this using `config` or `configFile` with the option `parser` or `filepath` ([#620](https://github.com/diffplug/spotless/pull/620)).
11+
### Removed
12+
* **BREAKING** the long-deprecated `<xml>` and `<css>` formats have been removed, in favor of the long-available [`<eclipseWtp>`](https://github.com/diffplug/spotless/tree/main/plugin-maven#eclipse-wtp) step which is available in every generic format.
13+
* This probably doesn't affect you, but if it does, you just need to change `<xml>...` into `<formats><format><eclipseWtp><type>XML</type>...`
14+
* In [`1.15.0` (released 2018-09-23)](#1150---2018-09-23), we added support for `xml` and `css` formats using the Eclipse WTP.
15+
* In [`1.18.0` (released 2019-02-11)](#1180---2019-02-11), we deprecated these, in favor of the generic `eclipseWtp` step which is available for all generic formats. This allows you to have multiple XML and CSS formats, rather than just one.
16+
* And now we removed them entirely.
1117

1218
## [1.31.3] - 2020-06-17
1319
### Changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,12 @@ public abstract class AbstractSpotlessMojo extends AbstractMojo {
102102
@Parameter
103103
private Kotlin kotlin;
104104

105-
/** The XML extension is discontinued. */
106-
@Parameter
107-
@Deprecated
108-
private com.diffplug.spotless.maven.xml.Xml xml;
109-
110105
@Parameter
111106
private Cpp cpp;
112107

113108
@Parameter
114109
private Typescript typescript;
115110

116-
/** The CSS extension is discontinued. */
117-
@Parameter
118-
@Deprecated
119-
private com.diffplug.spotless.maven.css.Css css;
120-
121111
@Parameter(property = "spotlessFiles")
122112
private String filePatterns;
123113

@@ -204,7 +194,7 @@ private FileLocator getFileLocator() {
204194
}
205195

206196
private List<FormatterFactory> getFormatterFactories() {
207-
return Stream.concat(formats.stream(), Stream.of(java, scala, kotlin, cpp, typescript, css, xml))
197+
return Stream.concat(formats.stream(), Stream.of(java, scala, kotlin, cpp, typescript))
208198
.filter(Objects::nonNull)
209199
.collect(toList());
210200
}

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2020 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.
@@ -20,7 +20,6 @@
2020

2121
import java.io.File;
2222
import java.util.ArrayList;
23-
import java.util.Arrays;
2423
import java.util.Collection;
2524
import java.util.List;
2625
import java.util.Objects;
@@ -57,12 +56,6 @@ public ArtifactResolver(RepositorySystem repositorySystem, RepositorySystemSessi
5756
this.log = Objects.requireNonNull(log);
5857
}
5958

60-
/** Use {@link ArtifactResolver#resolve(boolean, Collection)} instead. */
61-
@Deprecated
62-
public Set<File> resolve(String mavenCoordinate) {
63-
return resolve(true, Arrays.asList(mavenCoordinate));
64-
}
65-
6659
/**
6760
* Given a set of maven coordinates, returns a set of jars which include all
6861
* of the specified coordinates and optionally their transitive dependencies.

plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Css.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Eclipse.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)