Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump google-java-format to 1.19.2 #1971

Merged
merged 4 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
* New static method to `DiffMessageFormatter` which allows to retrieve diffs with their line numbers ([#1960](https://github.com/diffplug/spotless/issues/1960))
### Changes
* Use palantir-java-format 2.39.0 on Java 21. ([#1948](https://github.com/diffplug/spotless/pull/1948))
* Bump default `googleJavaFormat` version to latest `1.18.1` -> `1.19.2`. ([#1971](https://github.com/diffplug/spotless/pull/1971))

## [2.43.1] - 2023-12-04
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies {
gherkinCompileOnly 'io.cucumber:gherkin-utils:8.0.2'
gherkinCompileOnly 'org.slf4j:slf4j-api:2.0.0'
// googleJavaFormat
googleJavaFormatCompileOnly 'com.google.googlejavaformat:google-java-format:1.18.1'
googleJavaFormatCompileOnly 'com.google.googlejavaformat:google-java-format:1.19.2'
// gson
gsonCompileOnly 'com.google.code.gson:gson:2.10.1'
// jackson
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 DiffPlug
* Copyright 2016-2024 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down 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";
nedtwigg marked this conversation as resolved.
Show resolved Hide resolved
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 Expand Up @@ -83,7 +83,7 @@ public static FormatterStep create(String groupArtifact, String version, String
.addMin(11, "1.8") // we only support google-java-format >= 1.8 due to api changes
.addMin(16, "1.10.0") // java 16 requires at least 1.10.0 due to jdk api changes in JavaTokenizer
.addMin(21, "1.17.0") // java 21 requires at least 1.17.0 due to https://github.com/google/google-java-format/issues/898
.add(11, "1.18.1"); // default version
.add(11, "1.19.2"); // default version

public static String defaultGroupArtifact() {
return MAVEN_COORDINATE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 DiffPlug
* Copyright 2016-2024 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down 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:";
nedtwigg marked this conversation as resolved.
Show resolved Hide resolved
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
1 change: 1 addition & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Changes
* Use palantir-java-format 2.39.0 on Java 21. ([#1948](https://github.com/diffplug/spotless/pull/1948))
* Bump default `googleJavaFormat` version to latest `1.18.1` -> `1.19.2`. ([#1971](https://github.com/diffplug/spotless/pull/1971))

## [6.23.3] - 2023-12-04
**BREAKING CHANGE** `6.23.0` made breaking changes to the ABI of the `KotlinExtension` and `GroovyExtension`. Those are reflected retroactively now.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 DiffPlug
* Copyright 2016-2024 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down 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
1 change: 1 addition & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
* M2E support: Emit file specific errors during incremental build. ([#1960](https://github.com/diffplug/spotless/issues/1960))
### Changes
* Use palantir-java-format 2.39.0 on Java 21. ([#1948](https://github.com/diffplug/spotless/pull/1948))
* Bump default `googleJavaFormat` version to latest `1.18.1` -> `1.19.2`. ([#1971](https://github.com/diffplug/spotless/pull/1971))

## [2.41.1] - 2023-12-04
### Fixed
Expand Down
15 changes: 2 additions & 13 deletions testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 DiffPlug
* Copyright 2016-2024 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 @@ -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
Loading