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

0 commit comments

Comments
 (0)