Skip to content

Commit

Permalink
Merge pull request #630 from diffplug/remove-deprecated-break-maven
Browse files Browse the repository at this point in the history
Remove deprecated features from plugin-maven, and let plugin-gradle zombie-along
  • Loading branch information
nedtwigg authored Jul 1, 2020
2 parents 989abbe + 41a0d96 commit f8198b5
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 316 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
7 changes: 0 additions & 7 deletions lib/src/main/java/com/diffplug/spotless/css/package-info.java

This file was deleted.

7 changes: 0 additions & 7 deletions lib/src/main/java/com/diffplug/spotless/xml/package-info.java

This file was deleted.

1 change: 1 addition & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
*/
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<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.
* This probably doesn't affect you, but if it does, you just need to change `<xml>...` into `<formats><format><eclipseWtp><type>XML</type>...`
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -204,7 +194,7 @@ private FileLocator getFileLocator() {
}

private List<FormatterFactory> 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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -57,12 +56,6 @@ public ArtifactResolver(RepositorySystem repositorySystem, RepositorySystemSessi
this.log = Objects.requireNonNull(log);
}

/** Use {@link ArtifactResolver#resolve(boolean, Collection)} instead. */
@Deprecated
public Set<File> 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.
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit f8198b5

Please sign in to comment.