From 33976e6c4ee54f63d203494d3c6b421bfcc2e63d Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 22:25:13 -0700 Subject: [PATCH 1/9] Remove long-deprecated eclipse xml (long ago replaced by EclipseWtp): - it had a dedicated block in plugin-maven, which hasn't been in the documentation for a very long time - moved the code to plugin-gradle for now, since plugin-gradle will have a breaking change soon, but not yet --- .../diffplug/spotless/xml/package-info.java | 7 --- .../gradle/spotless/XmlExtension.java | 2 +- .../spotless/libdeprecated}/XmlDefaults.java | 4 +- .../libdeprecated}/XmlDefaultsTest.java | 2 +- .../spotless/maven/AbstractSpotlessMojo.java | 7 +-- .../com/diffplug/spotless/maven/xml/Xml.java | 53 ------------------- 6 files changed, 5 insertions(+), 70 deletions(-) delete mode 100644 lib/src/main/java/com/diffplug/spotless/xml/package-info.java rename {lib/src/main/java/com/diffplug/spotless/xml => plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated}/XmlDefaults.java (94%) rename {testlib/src/test/java/com/diffplug/spotless/xml => plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated}/XmlDefaultsTest.java (97%) delete mode 100644 plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Xml.java diff --git a/lib/src/main/java/com/diffplug/spotless/xml/package-info.java b/lib/src/main/java/com/diffplug/spotless/xml/package-info.java deleted file mode 100644 index 0d77d7be68..0000000000 --- a/lib/src/main/java/com/diffplug/spotless/xml/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@ReturnValuesAreNonnullByDefault -package com.diffplug.spotless.xml; - -import javax.annotation.ParametersAreNonnullByDefault; - -import com.diffplug.spotless.annotations.ReturnValuesAreNonnullByDefault; diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java index 35017e3970..0607442364 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java @@ -19,9 +19,9 @@ import org.gradle.api.Project; +import com.diffplug.gradle.spotless.libdeprecated.XmlDefaults; import com.diffplug.spotless.extra.EclipseBasedStepBuilder; import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep; -import com.diffplug.spotless.xml.XmlDefaults; /** * The XML extension is deprecated. Use the generic {@link FormatExtension} instead. diff --git a/lib/src/main/java/com/diffplug/spotless/xml/XmlDefaults.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaults.java similarity index 94% rename from lib/src/main/java/com/diffplug/spotless/xml/XmlDefaults.java rename to plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaults.java index d041d349c4..bf8210706f 100644 --- a/lib/src/main/java/com/diffplug/spotless/xml/XmlDefaults.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaults.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.diffplug.spotless.xml; +package com.diffplug.gradle.spotless.libdeprecated; import java.util.Arrays; import java.util.Collections; diff --git a/testlib/src/test/java/com/diffplug/spotless/xml/XmlDefaultsTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaultsTest.java similarity index 97% rename from testlib/src/test/java/com/diffplug/spotless/xml/XmlDefaultsTest.java rename to plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaultsTest.java index c0a9038406..373425d984 100644 --- a/testlib/src/test/java/com/diffplug/spotless/xml/XmlDefaultsTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/XmlDefaultsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.diffplug.spotless.xml; +package com.diffplug.gradle.spotless.libdeprecated; import static org.assertj.core.api.Assertions.assertThat; diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java index 0ce5cbae2d..ecad289473 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java @@ -102,11 +102,6 @@ public abstract class AbstractSpotlessMojo extends AbstractMojo { @Parameter private Kotlin kotlin; - /** The XML extension is discontinued. */ - @Parameter - @Deprecated - private com.diffplug.spotless.maven.xml.Xml xml; - @Parameter private Cpp cpp; @@ -204,7 +199,7 @@ private FileLocator getFileLocator() { } private List getFormatterFactories() { - return Stream.concat(formats.stream(), Stream.of(java, scala, kotlin, cpp, typescript, css, xml)) + return Stream.concat(formats.stream(), Stream.of(java, scala, kotlin, cpp, typescript, css)) .filter(Objects::nonNull) .collect(toList()); } diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Xml.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Xml.java deleted file mode 100644 index 915a5331a8..0000000000 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Xml.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2016 DiffPlug - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.diffplug.spotless.maven.xml; - -import java.util.Set; -import java.util.stream.Collectors; - -import com.diffplug.spotless.maven.FormatterFactory; -import com.diffplug.spotless.maven.generic.LicenseHeader; -import com.diffplug.spotless.xml.XmlDefaults; - -/** - * A {@link FormatterFactory} implementation that corresponds to {@code ...} configuration element. - *
- * It defines a formatter for XML/XSL/... source files that can execute both language agnostic (e.g. {@link LicenseHeader}) - * and xml-specific (e.g. {@link Eclipse}) steps. - *
- * The XML extension is discontinued. XML formatters are now part of the generic {@link FormatterFactory}. - */ -@Deprecated -public class Xml extends FormatterFactory { - - private static final Set DEFAULT_INCLUDES = XmlDefaults.FILE_FILTER - .stream().map(s -> "src/" + s).collect(Collectors.toSet()); - - @Override - public Set defaultIncludes() { - return DEFAULT_INCLUDES; - } - - public void addEclipse(Eclipse eclipse) { - addStepFactory(eclipse); - } - - @Override - public String licenseHeaderDelimiter() { - return XmlDefaults.DELIMITER_EXPR; - } - -} From d22acd5504d2400600252f6cdea80a195ee16b4f Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 22:30:06 -0700 Subject: [PATCH 2/9] Remove long-deprecated eclipse css (long ago replaced by EclipseWtp): - it had a dedicated block in plugin-maven, which hasn't been in the documentation for a very long time - moved the code to plugin-gradle for now, since plugin-gradle will have a breaking change soon, but not yet --- .../diffplug/spotless/css/package-info.java | 7 --- .../gradle/spotless/CssExtension.java | 2 +- .../spotless/libdeprecated}/CssDefaults.java | 4 +- .../libdeprecated}/CssDefaultsTest.java | 2 +- .../spotless/maven/AbstractSpotlessMojo.java | 7 +-- .../com/diffplug/spotless/maven/css/Css.java | 53 ------------------- .../diffplug/spotless/maven/css/Eclipse.java | 50 ----------------- 7 files changed, 5 insertions(+), 120 deletions(-) delete mode 100644 lib/src/main/java/com/diffplug/spotless/css/package-info.java rename {lib/src/main/java/com/diffplug/spotless/css => plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated}/CssDefaults.java (94%) rename {testlib/src/test/java/com/diffplug/spotless/css => plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated}/CssDefaultsTest.java (97%) delete mode 100644 plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Css.java delete mode 100644 plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Eclipse.java diff --git a/lib/src/main/java/com/diffplug/spotless/css/package-info.java b/lib/src/main/java/com/diffplug/spotless/css/package-info.java deleted file mode 100644 index 367ab208c8..0000000000 --- a/lib/src/main/java/com/diffplug/spotless/css/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -@ParametersAreNonnullByDefault -@ReturnValuesAreNonnullByDefault -package com.diffplug.spotless.css; - -import javax.annotation.ParametersAreNonnullByDefault; - -import com.diffplug.spotless.annotations.ReturnValuesAreNonnullByDefault; diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java index 9a51a48ca6..a9bd5842d4 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java @@ -19,7 +19,7 @@ import org.gradle.api.Project; -import com.diffplug.spotless.css.CssDefaults; +import com.diffplug.gradle.spotless.libdeprecated.CssDefaults; import com.diffplug.spotless.extra.EclipseBasedStepBuilder; import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep; diff --git a/lib/src/main/java/com/diffplug/spotless/css/CssDefaults.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaults.java similarity index 94% rename from lib/src/main/java/com/diffplug/spotless/css/CssDefaults.java rename to plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaults.java index e0b42dba74..edc28f724b 100644 --- a/lib/src/main/java/com/diffplug/spotless/css/CssDefaults.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaults.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.diffplug.spotless.css; +package com.diffplug.gradle.spotless.libdeprecated; import java.util.Arrays; import java.util.Collections; diff --git a/testlib/src/test/java/com/diffplug/spotless/css/CssDefaultsTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaultsTest.java similarity index 97% rename from testlib/src/test/java/com/diffplug/spotless/css/CssDefaultsTest.java rename to plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaultsTest.java index 006a5f64b5..3474d9dc52 100644 --- a/testlib/src/test/java/com/diffplug/spotless/css/CssDefaultsTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/libdeprecated/CssDefaultsTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.diffplug.spotless.css; +package com.diffplug.gradle.spotless.libdeprecated; import static org.assertj.core.api.Assertions.assertThat; diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java index ecad289473..36e2d65ec0 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java @@ -108,11 +108,6 @@ public abstract class AbstractSpotlessMojo extends AbstractMojo { @Parameter private Typescript typescript; - /** The CSS extension is discontinued. */ - @Parameter - @Deprecated - private com.diffplug.spotless.maven.css.Css css; - @Parameter(property = "spotlessFiles") private String filePatterns; @@ -199,7 +194,7 @@ private FileLocator getFileLocator() { } private List getFormatterFactories() { - return Stream.concat(formats.stream(), Stream.of(java, scala, kotlin, cpp, typescript, css)) + return Stream.concat(formats.stream(), Stream.of(java, scala, kotlin, cpp, typescript)) .filter(Objects::nonNull) .collect(toList()); } diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Css.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Css.java deleted file mode 100644 index 5307ab3447..0000000000 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Css.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2016 DiffPlug - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.diffplug.spotless.maven.css; - -import java.util.Set; -import java.util.stream.Collectors; - -import com.diffplug.spotless.css.CssDefaults; -import com.diffplug.spotless.maven.FormatterFactory; -import com.diffplug.spotless.maven.generic.LicenseHeader; - -/** - * A {@link FormatterFactory} implementation that corresponds to {@code ...} configuration element. - *
- * It defines a formatter for CSS source files that can execute both language agnostic (e.g. {@link LicenseHeader}) - * and css-specific (e.g. {@link Eclipse}) steps. - *
- * The CSS extension is discontinued. CSS formatters are now part of the generic {@link FormatterFactory}. - */ -@Deprecated -public class Css extends FormatterFactory { - - private static final Set DEFAULT_INCLUDES = CssDefaults.FILE_FILTER - .stream().map(s -> "src/" + s).collect(Collectors.toSet()); - - @Override - public Set defaultIncludes() { - return DEFAULT_INCLUDES; - } - - public void addEclipse(Eclipse eclipse) { - addStepFactory(eclipse); - } - - @Override - public String licenseHeaderDelimiter() { - return CssDefaults.DELIMITER_EXPR; - } - -} diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Eclipse.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Eclipse.java deleted file mode 100644 index 32865bef96..0000000000 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/css/Eclipse.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2016 DiffPlug - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.diffplug.spotless.maven.css; - -import java.io.File; -import java.util.Arrays; - -import org.apache.maven.plugins.annotations.Parameter; - -import com.diffplug.spotless.FormatterStep; -import com.diffplug.spotless.extra.EclipseBasedStepBuilder; -import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep; -import com.diffplug.spotless.maven.FormatterStepConfig; -import com.diffplug.spotless.maven.FormatterStepFactory; -import com.diffplug.spotless.maven.generic.EclipseWtp; - -/** CSS Eclipse is deprecated. Use {@link EclipseWtp} instead.*/ -@Deprecated -public class Eclipse implements FormatterStepFactory { - - @Parameter - private String file; - - @Parameter - private String version; - - @Override - public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) { - EclipseBasedStepBuilder eclipseConfig = EclipseWtpFormatterStep.createCssBuilder(stepConfig.getProvisioner()); - eclipseConfig.setVersion(version == null ? EclipseWtpFormatterStep.defaultVersion() : version); - if (null != file) { - File settingsFile = stepConfig.getFileLocator().locateFile(file); - eclipseConfig.setPreferences(Arrays.asList(settingsFile)); - } - return eclipseConfig.build(); - } -} From 6e807df22bd4aac6a16b2156ef4979c61751764b Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 22:32:22 -0700 Subject: [PATCH 3/9] Remove the long-stranded "EclipseXml" from plugin-maven. --- .../diffplug/spotless/maven/xml/Eclipse.java | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Eclipse.java diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Eclipse.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Eclipse.java deleted file mode 100644 index 6e1071fb57..0000000000 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/xml/Eclipse.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2016 DiffPlug - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.diffplug.spotless.maven.xml; - -import java.io.File; -import java.util.Arrays; - -import org.apache.maven.plugins.annotations.Parameter; - -import com.diffplug.spotless.FormatterStep; -import com.diffplug.spotless.extra.EclipseBasedStepBuilder; -import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep; -import com.diffplug.spotless.maven.FormatterStepConfig; -import com.diffplug.spotless.maven.FormatterStepFactory; -import com.diffplug.spotless.maven.generic.EclipseWtp; - -/** XML Eclipse is deprecated. Use {@link EclipseWtp} instead.*/ -@Deprecated -public class Eclipse implements FormatterStepFactory { - - @Parameter - private String file; - - @Parameter - private String version; - - @Override - public FormatterStep newFormatterStep(FormatterStepConfig stepConfig) { - EclipseBasedStepBuilder eclipseConfig = EclipseWtpFormatterStep.createXmlBuilder(stepConfig.getProvisioner()); - eclipseConfig.setVersion(version == null ? EclipseWtpFormatterStep.defaultVersion() : version); - if (null != file) { - File settingsFile = stepConfig.getFileLocator().locateFile(file); - eclipseConfig.setPreferences(Arrays.asList(settingsFile)); - } - return eclipseConfig.build(); - } -} From 6650d0ee56f08252adc87c0549219c0a4cc683e7 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 22:33:39 -0700 Subject: [PATCH 4/9] Remove tests for the deprecated functionality. --- .../maven/generic/LicenseHeaderTest.java | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderTest.java index 5bc34442d2..627b3e994b 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderTest.java @@ -50,25 +50,6 @@ public void fromContentCpp() throws Exception { assertFile(path).hasContent(cppLicense + '\n' + cppContent); } - /** The CSS extension is discontinued. */ - @Test - @Deprecated - public void fromContentCss() throws Exception { - String license = "/* my license */"; - writePomWithCssSteps( - "", - " ", - license, - " ", - ""); - - String path = "src/file.css"; - String content = "p {}"; - setFile(path).toContent(content); - mavenRunner().withArguments("spotless:apply").runNoError(); - assertFile(path).hasContent(license + '\n' + content); - } - @Test public void fromContentJava() throws Exception { writePomWithJavaSteps( @@ -133,23 +114,6 @@ public void fromContentKotlin() throws Exception { assertFile(path).hasContent(KOTLIN_LICENSE_HEADER + '\n' + noLicenseHeader); } - /** XML extension is discontinued. */ - @Test - @Deprecated - public void fromContentXml() throws Exception { - String license = " Licensed under Apache-2.0 "; - writePomWithXmlSteps( - "", - " ", - "<!--" + license + "-->", - " ", - ""); - String path = "src/test.xml"; - setFile(path).toContent(""); - mavenRunner().withArguments("spotless:apply").runNoError(); - assertFile(path).hasContent("\n"); - } - @Test public void unsupportedPackageInfo() throws Exception { testUnsupportedFile("package-info.java"); From 96c7816c5a1a0d3546bdc92b471918a58f2054a7 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 22:46:24 -0700 Subject: [PATCH 5/9] Move deprecated CSS part of EclipseWtpFormatterStep into plugin-gradle. --- .../extra/wtp/EclipseWtpFormatterStep.java | 9 ------ .../gradle/spotless/CssExtension.java | 30 ++++++++++++++++++- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java index fe45e846d7..83507825be 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java @@ -56,15 +56,6 @@ public static String defaultVersion() { return DEFAULT_VERSION; } - /** - * Provides default configuration for CSSformatter. - * Method is deprecated. Use {@link EclipseWtpFormatterStep#createBuilder(Provisioner)} instead. - */ - @Deprecated - public static EclipseBasedStepBuilder createCssBuilder(Provisioner provisioner) { - return new EclipseBasedStepBuilder(NAME, " - css", provisioner, state -> applyWithoutFile("EclipseCssFormatterStepImpl", state)); - } - /** * Provides default configuration for XML formatter. * Method is deprecated. Use {@link EclipseWtpFormatterStep#createBuilder(Provisioner)} instead. diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java index a9bd5842d4..376ffbb6ce 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java @@ -17,9 +17,15 @@ import static com.diffplug.gradle.spotless.PluginGradlePreconditions.requireElementsNonNull; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Properties; + import org.gradle.api.Project; import com.diffplug.gradle.spotless.libdeprecated.CssDefaults; +import com.diffplug.spotless.FormatterFunc; +import com.diffplug.spotless.Provisioner; import com.diffplug.spotless.extra.EclipseBasedStepBuilder; import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep; @@ -42,6 +48,28 @@ public EclipseConfig eclipse(String version) { return new EclipseConfig(version); } + private static EclipseBasedStepBuilder createCssBuilder(Provisioner provisioner) { + return new EclipseBasedStepBuilder(NAME, " - css", provisioner, state -> applyWithoutFile("EclipseCssFormatterStepImpl", state)); + } + + private static FormatterFunc applyWithoutFile(String className, EclipseBasedStepBuilder.State state) throws Exception { + Class formatterClazz = state.loadClass(FORMATTER_PACKAGE + className); + Object formatter = formatterClazz.getConstructor(Properties.class).newInstance(state.getPreferences()); + Method method = formatterClazz.getMethod(FORMATTER_METHOD, String.class); + return input -> { + try { + return (String) method.invoke(formatter, input); + } catch (InvocationTargetException exceptionWrapper) { + Throwable throwable = exceptionWrapper.getTargetException(); + Exception exception = (throwable instanceof Exception) ? (Exception) throwable : null; + throw (null == exception) ? exceptionWrapper : exception; + } + }; + } + + private static final String FORMATTER_PACKAGE = "com.diffplug.spotless.extra.eclipse.wtp."; + private static final String FORMATTER_METHOD = "format"; + /** * The CSS Eclipse configuration is deprecated. Use the {@link FormatExtension.EclipseWtpConfig} instead. */ @@ -50,7 +78,7 @@ public class EclipseConfig { private final EclipseBasedStepBuilder builder; EclipseConfig(String version) { - builder = EclipseWtpFormatterStep.createCssBuilder(provisioner()); + builder = createCssBuilder(provisioner()); builder.setVersion(version); addStep(builder.build()); } From ff35b009ea42a0a06b2689d6b6b6c1596dfe7718 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 22:47:50 -0700 Subject: [PATCH 6/9] Move deprecated XML part of EclipseWtpFormatterStep into plugin-gradle. --- .../spotless/extra/wtp/EclipseWtpFormatterStep.java | 9 --------- .../java/com/diffplug/gradle/spotless/XmlExtension.java | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java index 83507825be..22006a985a 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java @@ -56,15 +56,6 @@ public static String defaultVersion() { return DEFAULT_VERSION; } - /** - * Provides default configuration for XML formatter. - * Method is deprecated. Use {@link EclipseWtpFormatterStep#createBuilder(Provisioner)} instead. - */ - @Deprecated - public static EclipseBasedStepBuilder createXmlBuilder(Provisioner provisioner) { - return XML.createBuilder(provisioner); - } - private static FormatterFunc applyWithoutFile(String className, EclipseBasedStepBuilder.State state) throws Exception { Class formatterClazz = state.loadClass(FORMATTER_PACKAGE + className); Object formatter = formatterClazz.getConstructor(Properties.class).newInstance(state.getPreferences()); diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java index 0607442364..58ddc6c7f8 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/XmlExtension.java @@ -46,7 +46,7 @@ public class EclipseConfig { private final EclipseBasedStepBuilder builder; EclipseConfig(String version) { - builder = EclipseWtpFormatterStep.createXmlBuilder(provisioner()); + builder = EclipseWtpFormatterStep.XML.createBuilder(provisioner()); builder.setVersion(version); addStep(builder.build()); } From 332ffef98fc47c50ebc6c2825de1d9816efc7ec6 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 22:55:49 -0700 Subject: [PATCH 7/9] Remove deprecated parts of plugin-maven's internals. --- .../diffplug/spotless/maven/ArtifactResolver.java | 9 +-------- .../spotless/maven/MavenIntegrationHarness.java | 12 ------------ 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/ArtifactResolver.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/ArtifactResolver.java index af6021d0ce..d0c8cb729a 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/ArtifactResolver.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/ArtifactResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2020 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Objects; @@ -57,12 +56,6 @@ public ArtifactResolver(RepositorySystem repositorySystem, RepositorySystemSessi this.log = Objects.requireNonNull(log); } - /** Use {@link ArtifactResolver#resolve(boolean, Collection)} instead. */ - @Deprecated - public Set resolve(String mavenCoordinate) { - return resolve(true, Arrays.asList(mavenCoordinate)); - } - /** * Given a set of maven coordinates, returns a set of jars which include all * of the specified coordinates and optionally their transitive dependencies. diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java index f9c2564631..875e483271 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java @@ -110,22 +110,10 @@ protected void writePomWithKotlinSteps(String... steps) throws IOException { writePom(groupWithSteps("kotlin", steps)); } - /** The XML extension is discontinued. */ - @Deprecated - protected void writePomWithXmlSteps(String... steps) throws IOException { - writePom(groupWithSteps("xml", steps)); - } - protected void writePomWithCppSteps(String... steps) throws IOException { writePom(groupWithSteps("cpp", steps)); } - /** The CSS extension is discontinued. */ - @Deprecated - protected void writePomWithCssSteps(String... steps) throws IOException { - writePom(groupWithSteps("css", steps)); - } - protected void writePomWithTypescriptSteps(String... steps) throws IOException { writePom(groupWithSteps("typescript", steps)); } From dd3d7a25c205b12a6e33a287de23446afa4f3763 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 23:00:45 -0700 Subject: [PATCH 8/9] Update changelogs. --- CHANGES.md | 3 ++- plugin-gradle/CHANGES.md | 1 + plugin-maven/CHANGES.md | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4515786d3f..1fa3003f17 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,8 +19,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * 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)). * This change also allows the gradle plugin to work with the remote buildcache (fixes [#280](https://github.com/diffplug/spotless/issues/280)). * **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)) -* **BREAKING** Removed all deprecated methods and classes. +* **BREAKING** Removed all deprecated methods and classes from `lib` and `lib-extra`. * [#629](https://github.com/diffplug/spotless/pull/629) removes the code which wasn't being used in plugin-gradle or plugin-maven. + * [#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`. ## [1.34.1] - 2020-06-17 ### Changed diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 8e2124f016..d0d44837a1 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -8,6 +8,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * 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). * `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)) +* (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)) ### Fixed * 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)) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 17bfdf80c4..881cd108e3 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -8,6 +8,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * 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)). * 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)) * `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)). +### Removed +* **BREAKING** In [`1.18.0` (released 2019-02-11)](#1180---2019-02-11), we deprecated the `` and `` elements, in favor of the generic `eclipseWtp` step. ## [1.31.3] - 2020-06-17 ### Changed From 41a0d963f448522a78594d15a831029bcf2134a7 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 29 Jun 2020 23:24:32 -0700 Subject: [PATCH 9/9] Better changelog for maven. --- plugin-maven/CHANGES.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 881cd108e3..ce9d813d0e 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -9,7 +9,11 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( * 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)) * `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)). ### Removed -* **BREAKING** In [`1.18.0` (released 2019-02-11)](#1180---2019-02-11), we deprecated the `` and `` elements, in favor of the generic `eclipseWtp` step. +* **BREAKING** the long-deprecated `` and `` formats have been removed, in favor of the long-available [``](https://github.com/diffplug/spotless/tree/main/plugin-maven#eclipse-wtp) step which is available in every generic format. + * This probably doesn't affect you, but if it does, you just need to change `...` into `XML...` + * In [`1.15.0` (released 2018-09-23)](#1150---2018-09-23), we added support for `xml` and `css` formats using the Eclipse WTP. + * 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. + * And now we removed them entirely. ## [1.31.3] - 2020-06-17 ### Changed