diff --git a/CHANGES.md b/CHANGES.md index abc9799ba6..887b2b062b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,8 +20,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/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..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,24 +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. - */ - @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/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/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/CHANGES.md b/plugin-gradle/CHANGES.md index fae34fcaee..444f749909 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)) * `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)). 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..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.spotless.css.CssDefaults; +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()); } 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..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 @@ -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. @@ -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()); } 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/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/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/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/CHANGES.md b/plugin-maven/CHANGES.md index 17bfdf80c4..ce9d813d0e 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -8,6 +8,12 @@ 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** 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 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..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 @@ -102,22 +102,12 @@ 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; @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; @@ -204,7 +194,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)) .filter(Objects::nonNull) .collect(toList()); } 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/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(); - } -} 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(); - } -} 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; - } - -} 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)); } 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");