diff --git a/changelog/@unreleased/pr-358.v2.yml b/changelog/@unreleased/pr-358.v2.yml new file mode 100644 index 000000000..851faaffb --- /dev/null +++ b/changelog/@unreleased/pr-358.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Update spotless to 5.7.0 + links: + - https://github.com/palantir/palantir-java-format/pull/358 diff --git a/gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPlugin.java b/gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPlugin.java index fc0fa442d..9434e556b 100644 --- a/gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPlugin.java +++ b/gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPlugin.java @@ -15,18 +15,25 @@ */ package com.palantir.javaformat.gradle; +import com.google.common.collect.ImmutableList; import org.gradle.api.Plugin; import org.gradle.api.Project; public class PalantirJavaFormatSpotlessPlugin implements Plugin { + // The spotless gradle plugin got renamed to 'com.diffplug.spotless' at version 5.0.0 + private static final ImmutableList SPOTLESS_PLUGINS = + ImmutableList.of("com.diffplug.gradle.spotless", "com.diffplug.spotless"); + @Override public void apply(Project project) { project.getRootProject().getPluginManager().apply(PalantirJavaFormatProviderPlugin.class); project.getPluginManager().withPlugin("java", plugin -> { - project.getPluginManager().withPlugin("com.diffplug.gradle.spotless", spotlessPlugin -> { - SpotlessInterop.addSpotlessJavaStep(project, PalantirJavaFormatProviderPlugin.CONFIGURATION_NAME); - }); + SPOTLESS_PLUGINS.forEach( + spotlessPluginId -> project.getPluginManager().withPlugin(spotlessPluginId, spotlessPlugin -> { + SpotlessInterop.addSpotlessJavaStep( + project, PalantirJavaFormatProviderPlugin.CONFIGURATION_NAME); + })); }); } } diff --git a/gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.groovy b/gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.groovy index 354f2fa79..2aeb66e1c 100644 --- a/gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.groovy +++ b/gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.groovy @@ -23,11 +23,7 @@ class PalantirJavaFormatSpotlessPluginTest extends IntegrationTestKitSpec { void setup() { buildFile << """ - buildscript { - dependencies { - classpath "com.diffplug.spotless:spotless-plugin-gradle:3.26.1" - } - } + // The 'com.diffplug.spotless:spotless-plugin-gradle' dependency is already added by palantir-java-format plugins { id 'java' id 'com.palantir.java-format' @@ -41,7 +37,7 @@ class PalantirJavaFormatSpotlessPluginTest extends IntegrationTestKitSpec { def "formats with spotless when spotless is applied"() { buildFile << """ - apply plugin: 'com.diffplug.gradle.spotless' + apply plugin: 'com.diffplug.spotless' """.stripIndent() file('src/main/java/Main.java').text = invalidJavaFile diff --git a/versions.lock b/versions.lock index ff6309318..672a95e4c 100644 --- a/versions.lock +++ b/versions.lock @@ -2,9 +2,9 @@ com.diffplug.durian:durian-collect:1.2.0 (3 constraints: 4d313bd2) com.diffplug.durian:durian-core:1.2.0 (4 constraints: 2640ae56) com.diffplug.durian:durian-io:1.2.0 (1 constraints: 1313c62d) -com.diffplug.spotless:spotless-lib:2.1.0 (2 constraints: 822455a4) -com.diffplug.spotless:spotless-lib-extra:2.1.0 (1 constraints: 1313c82d) -com.diffplug.spotless:spotless-plugin-gradle:4.5.1 (1 constraints: 0c050f36) +com.diffplug.spotless:spotless-lib:2.9.0 (2 constraints: 92242da6) +com.diffplug.spotless:spotless-lib-extra:2.9.0 (1 constraints: 1b13e02d) +com.diffplug.spotless:spotless-plugin-gradle:5.7.0 (1 constraints: 0e051936) com.fasterxml.jackson.core:jackson-annotations:2.11.1 (1 constraints: 85123021) com.fasterxml.jackson.core:jackson-core:2.11.1 (3 constraints: 5e41611c) com.fasterxml.jackson.core:jackson-databind:2.11.1 (3 constraints: 10341167) diff --git a/versions.props b/versions.props index 8f2bfeb78..3c3b043a9 100644 --- a/versions.props +++ b/versions.props @@ -1,4 +1,4 @@ -com.diffplug.spotless:spotless-plugin-gradle = 4.5.1 +com.diffplug.spotless:spotless-plugin-gradle = 5.7.0 com.github.ben-manes.caffeine:caffeine = 2.8.5 com.google.auto.service:auto-service = 1.0-rc6 com.google.code.findbugs:jsr305 = 3.0.2