Skip to content

Commit

Permalink
Remove the workaround for pinning Guava
Browse files Browse the repository at this point in the history
This reverts commit a6495ed
  • Loading branch information
Goooler committed Jan 8, 2024
1 parent 18b35ab commit 2d3c0bb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> JVM_SUPPORT = Jvm.<String> 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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 1 addition & 12 deletions testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -68,15 +65,7 @@ private static Provisioner createWithRepositories(Consumer<RepositoryHandler> 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<String> 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);
Expand Down

0 comments on commit 2d3c0bb

Please sign in to comment.