From 2d3c0bbd1abb56a16d3c74b1e3ebab876e21dd11 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 19 Dec 2023 13:58:20 +0800 Subject: [PATCH] Remove the workaround for pinning Guava This reverts commit a6495edd --- .../spotless/java/GoogleJavaFormatStep.java | 2 +- .../spotless/java/PalantirJavaFormatStep.java | 2 +- .../diffplug/gradle/spotless/GradleProvisioner.java | 13 +------------ .../java/com/diffplug/spotless/TestProvisioner.java | 13 +------------ 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java b/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java index 1660d57710..7d577064f1 100644 --- a/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java +++ b/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java @@ -35,7 +35,7 @@ private GoogleJavaFormatStep() {} private static final boolean DEFAULT_REORDER_IMPORTS = false; private static final boolean DEFAULT_FORMAT_JAVADOC = true; static final String NAME = "google-java-format"; - public static final String MAVEN_COORDINATE = "com.google.googlejavaformat:google-java-format"; + static final String MAVEN_COORDINATE = "com.google.googlejavaformat:google-java-format"; /** Creates a step which formats everything - code, import order, and unused imports. */ public static FormatterStep create(Provisioner provisioner) { diff --git a/lib/src/main/java/com/diffplug/spotless/java/PalantirJavaFormatStep.java b/lib/src/main/java/com/diffplug/spotless/java/PalantirJavaFormatStep.java index 88488ac2d7..1f5bdf17df 100644 --- a/lib/src/main/java/com/diffplug/spotless/java/PalantirJavaFormatStep.java +++ b/lib/src/main/java/com/diffplug/spotless/java/PalantirJavaFormatStep.java @@ -29,7 +29,7 @@ private PalantirJavaFormatStep() {} private static final String DEFAULT_STYLE = "PALANTIR"; private static final String NAME = "palantir-java-format"; - public static final String MAVEN_COORDINATE = "com.palantir.javaformat:palantir-java-format:"; + private static final String MAVEN_COORDINATE = "com.palantir.javaformat:palantir-java-format:"; private static final Jvm.Support JVM_SUPPORT = Jvm. support(NAME).add(8, "1.1.0").add(11, "2.28.0").add(21, "2.39.0"); /** Creates a step which formats everything - code, import order, and unused imports. */ diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java index 6bb8c1b50e..9003445ddd 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java @@ -36,8 +36,6 @@ import com.diffplug.common.base.Unhandled; import com.diffplug.common.collect.ImmutableList; import com.diffplug.spotless.Provisioner; -import com.diffplug.spotless.java.GoogleJavaFormatStep; -import com.diffplug.spotless.java.PalantirJavaFormatStep; /** Should be package-private. */ class GradleProvisioner { @@ -119,16 +117,7 @@ private static Provisioner forConfigurationContainer(Project project, Configurat + new Request(withTransitives, mavenCoords).hashCode()); mavenCoords.stream() .map(dependencies::create) - .forEach(dependency -> { - config.getDependencies().add(dependency); - String coordinate = dependency.getGroup() + ":" + dependency.getName(); - if (coordinate.startsWith(GoogleJavaFormatStep.MAVEN_COORDINATE) || - coordinate.startsWith(PalantirJavaFormatStep.MAVEN_COORDINATE)) { - // Use Guava 32.1.3, see https://github.com/google/guava/issues/6657. - // TODO: May remove this after https://github.com/google/google-java-format/pull/996 and https://github.com/palantir/palantir-java-format/issues/957 are released. - config.getDependencies().add(dependencies.create("com.google.guava:guava:32.1.3-jre")); - } - }); + .forEach(config.getDependencies()::add); config.setDescription(mavenCoords.toString()); config.setTransitive(withTransitives); config.setCanBeConsumed(false); diff --git a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java index 53a5cfed30..04c4476804 100644 --- a/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java +++ b/testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; -import java.util.stream.Stream; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; @@ -42,8 +41,6 @@ import com.diffplug.common.base.Suppliers; import com.diffplug.common.collect.ImmutableSet; import com.diffplug.common.io.Files; -import com.diffplug.spotless.java.GoogleJavaFormatStep; -import com.diffplug.spotless.java.PalantirJavaFormatStep; public class TestProvisioner { public static Project gradleProject(File dir) { @@ -68,15 +65,7 @@ private static Provisioner createWithRepositories(Consumer re Project project = TestProvisioner.gradleProject(tempDir); repoConfig.accept(project.getRepositories()); return (withTransitives, mavenCoords) -> { - boolean forceGuava = mavenCoords.stream().anyMatch(coordinate -> coordinate.startsWith(GoogleJavaFormatStep.MAVEN_COORDINATE) || - coordinate.startsWith(PalantirJavaFormatStep.MAVEN_COORDINATE)); - Stream coordinateStream = mavenCoords.stream(); - if (forceGuava) { - // Use Guava 32.1.3, see https://github.com/google/guava/issues/6657. - // TODO: May remove this after https://github.com/google/google-java-format/pull/996 and https://github.com/palantir/palantir-java-format/issues/957 are released. - coordinateStream = Stream.concat(coordinateStream, Stream.of("com.google.guava:guava:32.1.3-jre")); - } - Dependency[] deps = coordinateStream + Dependency[] deps = mavenCoords.stream() .map(project.getDependencies()::create) .toArray(Dependency[]::new); Configuration config = project.getConfigurations().detachedConfiguration(deps);