diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 023cb621c0..2a004e0835 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -39,10 +39,10 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
- jre: [ 17, 21, 24 ] # Test on all supported LTS and latest JDK.
+ jre: [ 17, 21, 25, 26 ] # Test on all supported LTS and latest JDK.
include:
- os: windows-latest
- jre: 24 # Test on the latest JDK for speeds.
+ jre: 26 # Test on the latest JDK for speeds.
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
@@ -67,10 +67,10 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
- jre: [ 17, 21, 24 ] # Test on all supported LTS and latest JDK.
+ jre: [ 17, 21, 25, 26 ] # Test on all supported LTS and latest JDK.
include:
- os: windows-latest
- jre: 24 # Test on the latest JDK for speeds.
+ jre: 26 # Test on the latest JDK for speeds.
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
diff --git a/lib-extra/src/test/java/com/diffplug/spotless/extra/GitRachetMergeBaseTest.java b/lib-extra/src/test/java/com/diffplug/spotless/extra/GitRachetMergeBaseTest.java
index f8592a895d..7645b9d4f6 100644
--- a/lib-extra/src/test/java/com/diffplug/spotless/extra/GitRachetMergeBaseTest.java
+++ b/lib-extra/src/test/java/com/diffplug/spotless/extra/GitRachetMergeBaseTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2025 DiffPlug
+ * Copyright 2020-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -331,6 +331,6 @@ private Git initRepo() throws IllegalStateException, GitAPIException, IOExceptio
private void addAndCommit(Git git, String message) throws GitAPIException {
git.add().addFilepattern(".").call();
- git.commit().setMessage(message).call();
+ git.commit().setSign(false).setMessage(message).call();
}
}
diff --git a/lib/spotbugs-exclude.xml b/lib/spotbugs-exclude.xml
index 1739443b83..807778a209 100644
--- a/lib/spotbugs-exclude.xml
+++ b/lib/spotbugs-exclude.xml
@@ -20,4 +20,9 @@
+
+
+
+
+
diff --git a/lib/src/main/java/com/diffplug/spotless/rdf/RdfFormatterStep.java b/lib/src/main/java/com/diffplug/spotless/rdf/RdfFormatterStep.java
index 8a1cd44922..518aaa4fcd 100644
--- a/lib/src/main/java/com/diffplug/spotless/rdf/RdfFormatterStep.java
+++ b/lib/src/main/java/com/diffplug/spotless/rdf/RdfFormatterStep.java
@@ -22,6 +22,7 @@
import java.util.Objects;
import java.util.TreeMap;
+import com.diffplug.spotless.FormatterFunc;
import com.diffplug.spotless.FormatterStep;
import com.diffplug.spotless.JarState;
import com.diffplug.spotless.Jvm;
@@ -53,10 +54,10 @@ public static State state(RdfFormatterStep step) {
return new State(step.config, step.turtleFormatterStyle, step.jarState.get());
}
- public static RdfFormatterFunc formatterFunc(State state)
+ public static FormatterFunc formatterFunc(State state)
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
var formatterFunc = new RdfFormatterFunc(state);
- return (RdfFormatterFunc) JVM_SUPPORT.suggestLaterVersionOnError(state.config.getTurtleFormatterVersion(), formatterFunc);
+ return JVM_SUPPORT.suggestLaterVersionOnError(state.config.getTurtleFormatterVersion(), formatterFunc);
}
public RdfFormatterStep(JarState.Promised jarState, RdfFormatterConfig config,
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GitRatchetGradleTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GitRatchetGradleTest.java
index 0e3cb3f283..be48e23b9d 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GitRatchetGradleTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GitRatchetGradleTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2025 DiffPlug
+ * Copyright 2016-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ void singleProjectExhaustive(int useConfigCache) throws Exception {
"}");
setFile(TEST_PATH).toContent("HELLO");
git.add().addFilepattern(TEST_PATH).call();
- git.commit().setMessage("Initial state").call();
+ git.commit().setSign(false).setMessage("Initial state").call();
// tag this initial state as the baseline for spotless to ratchet from
git.tag().setName("baseline").call();
@@ -271,7 +271,7 @@ public BuildResultAssertion outcome(String taskPath, TaskOutcome expected) {
private RevCommit addAndCommit(Git git) throws NoFilepatternException, GitAPIException {
PersonIdent emptyPerson = new PersonIdent("jane doe", "jane@doe.com", new Date(0), TimeZone.getTimeZone("UTC"));
git.add().addFilepattern(".").call();
- return git.commit().setMessage("baseline")
+ return git.commit().setSign(false).setMessage("baseline")
.setCommitter(emptyPerson)
.setAuthor(emptyPerson)
.call();
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java
index e7fc9d4b74..dde872d3e5 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2023 DiffPlug
+ * Copyright 2016-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,11 @@
import org.junit.jupiter.api.Test;
+import com.diffplug.spotless.Jvm;
+
class GoogleJavaFormatIntegrationTest extends GradleIntegrationHarness {
+ private static final String NON_DEFAULT_VERSION = Jvm.version() <= 17 ? "1.27.0" : "1.34.1";
+
@Test
void integration() throws IOException {
setFile("build.gradle").toLines(
@@ -31,7 +35,7 @@ void integration() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0')",
+ " googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
" }",
"}");
@@ -41,7 +45,7 @@ void integration() throws IOException {
checkRunsThenUpToDate();
replace("build.gradle",
- "googleJavaFormat('1.17.0')",
+ "googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
"googleJavaFormat()");
checkRunsThenUpToDate();
}
@@ -57,7 +61,7 @@ void integrationWithReorderImports() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0').aosp().reorderImports(true)",
+ " googleJavaFormat('" + NON_DEFAULT_VERSION + "').aosp().reorderImports(true)",
" }",
"}");
@@ -67,7 +71,7 @@ void integrationWithReorderImports() throws IOException {
checkRunsThenUpToDate();
replace("build.gradle",
- "googleJavaFormat('1.17.0')",
+ "googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
"googleJavaFormat()");
checkRunsThenUpToDate();
}
@@ -83,7 +87,7 @@ void integrationWithSkipJavadocFormatting() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0').skipJavadocFormatting()",
+ " googleJavaFormat('" + NON_DEFAULT_VERSION + "').skipJavadocFormatting()",
" }",
"}");
@@ -93,7 +97,7 @@ void integrationWithSkipJavadocFormatting() throws IOException {
checkRunsThenUpToDate();
replace("build.gradle",
- "googleJavaFormat('1.17.0')",
+ "googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
"googleJavaFormat()");
checkRunsThenUpToDate();
}
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GradleIntegrationHarness.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GradleIntegrationHarness.java
index 0e223a3409..c29d98329d 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GradleIntegrationHarness.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GradleIntegrationHarness.java
@@ -55,9 +55,12 @@ public enum GradleVersionSupport {
GradleVersionSupport(String version) {
String minVersionForRunningJRE;
switch (Jvm.version()) {
- case 26:
- throw new IllegalStateException("Gradle does not yet support running on Java 26. " +
+ case 27:
+ throw new IllegalStateException("Gradle does not yet support running on Java 27. " +
"You need to update the case ref to https://docs.gradle.org/current/userguide/compatibility.html.");
+ case 26:
+ minVersionForRunningJRE = "9.4.0";
+ break;
case 25:
minVersionForRunningJRE = "9.1.0";
break;
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java
index f986d83717..610a35c9f7 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2025 DiffPlug
+ * Copyright 2016-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ class KotlinExtensionTest extends GradleIntegrationHarness {
void integrationDiktat() throws IOException {
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
@@ -49,7 +49,7 @@ void integrationKtfmtDropboxStyleWithPublicApi() throws IOException {
setFile("build.gradle.kts").toLines(
"import com.diffplug.spotless.kotlin.KtfmtStep.TrailingCommaManagementStrategy",
"plugins {",
- " id(\"org.jetbrains.kotlin.jvm\") version \"1.6.21\"",
+ " id(\"org.jetbrains.kotlin.jvm\") version \"2.1.10\"",
" id(\"com.diffplug.spotless\")",
"}",
"repositories { mavenCentral() }",
@@ -73,7 +73,7 @@ void integrationKtfmtDropboxStyleWithPublicApi() throws IOException {
void withExperimentalEditorConfigOverride() throws IOException {
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
@@ -97,7 +97,7 @@ void testWithInvalidEditorConfigFile() throws IOException {
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
@@ -117,7 +117,7 @@ void testReadCodeStyleFromEditorConfigFile() throws IOException {
setFile(".editorconfig").toResource("kotlin/ktlint/ktlint_official/.editorconfig");
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
@@ -134,7 +134,7 @@ void testEditorConfigOverrideWithUnsetCodeStyleDoesNotOverrideEditorConfigCodeSt
setFile(".editorconfig").toResource("kotlin/ktlint/ktlint_official/.editorconfig");
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
@@ -153,7 +153,7 @@ void testSetEditorConfigCanOverrideEditorConfigFile() throws IOException {
setFile(".editorconfig").toResource("kotlin/ktlint/intellij_idea/.editorconfig");
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
@@ -171,7 +171,7 @@ void testSetEditorConfigCanOverrideEditorConfigFile() throws IOException {
void withCustomRuleSetApply() throws IOException {
setFile("build.gradle.kts").toLines(
"plugins {",
- " id(\"org.jetbrains.kotlin.jvm\") version \"1.6.21\"",
+ " id(\"org.jetbrains.kotlin.jvm\") version \"2.1.10\"",
" id(\"com.diffplug.spotless\")",
"}",
"repositories { mavenCentral() }",
@@ -195,7 +195,7 @@ void withCustomRuleSetApply() throws IOException {
void testWithHeader() throws IOException {
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
@@ -214,7 +214,7 @@ void testWithHeader() throws IOException {
void testWithCustomMaxWidthDefaultStyleKtfmt() throws IOException {
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java
index c607c36912..b356bef180 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2023 DiffPlug
+ * Copyright 2016-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ class KotlinGradleExtensionTest extends KotlinExtensionTest {
void testTarget(boolean useDefaultTarget) throws IOException {
setFile("build.gradle").toLines(
"plugins {",
- " id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
+ " id 'org.jetbrains.kotlin.jvm' version '2.1.10'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/LicenseHeaderTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/LicenseHeaderTest.java
index 5071762b5f..fc8d63e4a9 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/LicenseHeaderTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/LicenseHeaderTest.java
@@ -163,7 +163,7 @@ void filterByContentPatternTest() throws IOException {
@Test
void ratchetFrom() throws Exception {
try (Git git = Git.init().setDirectory(rootFolder()).call()) {
- git.commit().setMessage("First commit").call();
+ git.commit().setSign(false).setMessage("First commit").call();
}
setLicenseStep("licenseHeader('/** $YEAR */')\nratchetFrom 'HEAD'");
testSuiteUpdateWithLatest(true);
@@ -172,7 +172,7 @@ void ratchetFrom() throws Exception {
@Test
void ratchetFromButUpdateFalse() throws Exception {
try (Git git = Git.init().setDirectory(rootFolder()).call()) {
- git.commit().setMessage("First commit").call();
+ git.commit().setSign(false).setMessage("First commit").call();
}
try (Git ignored = Git.init().setDirectory(rootFolder()).call()) {
setLicenseStep("licenseHeader('/** $YEAR */').updateYearWithLatest(false)\nratchetFrom 'HEAD'");
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/MultiProjectTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/MultiProjectTest.java
index 3403bbfaad..38d9143623 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/MultiProjectTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/MultiProjectTest.java
@@ -21,6 +21,7 @@
import org.junit.jupiter.api.Test;
import com.diffplug.common.base.StringPrinter;
+import com.diffplug.spotless.java.GoogleJavaFormatStep;
class MultiProjectTest extends GradleIntegrationHarness {
private static final int N = 100;
@@ -47,7 +48,7 @@ void createSubproject(String name) throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0')",
+ " googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "')",
" }",
"}");
setFile(name + "/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
@@ -71,7 +72,7 @@ public void hasRootSpotless() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0')",
+ " googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "')",
" }",
"}");
setFile("test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
@@ -88,7 +89,7 @@ public void predeclaredFails() throws IOException {
"spotless { predeclareDeps() }");
createNSubprojects();
Assertions.assertThat(gradleRunner().withArguments("spotlessApply").buildAndFail().getOutput())
- .contains("Add a step with [com.google.googlejavaformat:google-java-format:1.17.0] into the `spotlessPredeclare` block in the root project.");
+ .contains("Add a step with [com.google.googlejavaformat:google-java-format:" + GoogleJavaFormatStep.defaultVersion() + "] into the `spotlessPredeclare` block in the root project.");
}
@Test
@@ -101,7 +102,7 @@ public void predeclaredSucceeds_deprecatedAPI() throws IOException {
"spotless { predeclareDeps() }",
"",
"spotlessPredeclare {",
- " java { googleJavaFormat('1.17.0') }",
+ " java { googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "') }",
"}");
createNSubprojects();
gradleRunner().withArguments("spotlessApply").build();
@@ -119,7 +120,7 @@ public void predeclaredFromBuildscriptSucceeds_deprecatedAPI() throws IOExceptio
"repositories { mavenCentral() }",
"spotless { predeclareDepsFromBuildscript() }",
"spotlessPredeclare {",
- " java { googleJavaFormat('1.17.0') }",
+ " java { googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "') }",
"}");
createNSubprojects();
gradleRunner().withArguments("spotlessApply").build();
@@ -138,7 +139,7 @@ public void predeclaredFromBuildscriptInPredeclareBlockSucceeds() throws IOExcep
"",
"spotlessPredeclare {",
" fromBuildscriptRepositories()",
- " java { googleJavaFormat('1.17.0') }",
+ " java { googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "') }",
"}");
createNSubprojects();
gradleRunner().withArguments("spotlessApply").build();
@@ -152,7 +153,7 @@ public void predeclaredOrderingIsFlexible() throws IOException {
"}",
"repositories { mavenCentral() }",
"spotlessPredeclare {",
- " java { googleJavaFormat('1.17.0') }",
+ " java { googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "') }",
"}",
"spotless { predeclareDeps() }");
createNSubprojects();
@@ -169,11 +170,11 @@ public void predeclaredDepsRegression() throws IOException {
" predeclareDeps()",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0')",
+ " googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "')",
" }",
"}",
"spotlessPredeclare {",
- " java { googleJavaFormat('1.17.0') }",
+ " java { googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "') }",
"}");
setFile("test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
setFile("sub/build.gradle").toLines(
@@ -182,11 +183,11 @@ public void predeclaredDepsRegression() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0')",
+ " googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "')",
" }",
"}");
setFile("sub/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
- gradleRunner().withGradleVersion("8.14").withArguments("spotlessApply").build();
+ gradleRunner().withArguments("spotlessApply").build();
}
@Test
@@ -197,7 +198,7 @@ public void predeclaredWithoutSpotlessBlockSucceeds() throws IOException {
"}",
"repositories { mavenCentral() }",
"spotlessPredeclare {",
- " java { googleJavaFormat('1.17.0') }",
+ " java { googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "') }",
"}");
createNSubprojects();
gradleRunner().withArguments("spotlessApply").build();
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PalantirJavaFormatIntegrationTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PalantirJavaFormatIntegrationTest.java
index 9990039cd3..71999ebde2 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PalantirJavaFormatIntegrationTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PalantirJavaFormatIntegrationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022-2024 DiffPlug
+ * Copyright 2022-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ void formatJavaDoc() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " palantirJavaFormat('2.39.0').formatJavadoc(true)",
+ " palantirJavaFormat('2.80.0').formatJavadoc(true)",
" }",
"}");
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/RegisterDependenciesTaskBuildDirTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/RegisterDependenciesTaskBuildDirTest.java
index 0fedd8e099..368a832108 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/RegisterDependenciesTaskBuildDirTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/RegisterDependenciesTaskBuildDirTest.java
@@ -20,6 +20,8 @@
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
+import com.diffplug.spotless.java.GoogleJavaFormatStep;
+
class RegisterDependenciesTaskBuildDirTest extends GradleIntegrationHarness {
@Test
void unitOutputFollowsCustomBuildDirectory() throws IOException {
@@ -34,7 +36,7 @@ void unitOutputFollowsCustomBuildDirectory() throws IOException {
"spotless { predeclareDeps() }",
"",
"spotlessPredeclare {",
- " java { googleJavaFormat('1.17.0') }",
+ " java { googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "') }",
"}",
"",
"layout.buildDirectory = layout.projectDirectory.dir('custom-build')");
@@ -45,7 +47,7 @@ void unitOutputFollowsCustomBuildDirectory() throws IOException {
"spotless {",
" java {",
" target 'src/main/java/**/*.java'",
- " googleJavaFormat('1.17.0')",
+ " googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "')",
" }",
"}");
setFile("sub/src/main/java/Hello.java").toLines(
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessPredeclareIntegrationTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessPredeclareIntegrationTest.java
index 5f54de218d..a98cb9b792 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessPredeclareIntegrationTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessPredeclareIntegrationTest.java
@@ -23,6 +23,8 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
+import com.diffplug.spotless.java.GoogleJavaFormatStep;
+
/**
* Integration tests for the spotlessPredeclare feature, which allows dependencies
* to be predeclared in the root project and reused across all subprojects to avoid
@@ -41,9 +43,9 @@ void predeclareSucceedsWithMavenDependencies() throws IOException {
repositories { mavenCentral() }
spotless { predeclareDeps() }
spotlessPredeclare {
- java { googleJavaFormat('1.17.0') }
+ java { googleJavaFormat('%s') }
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("settings.gradle").toContent("include 'sub'");
setFile("sub/build.gradle").toContent("""
plugins {
@@ -53,10 +55,10 @@ void predeclareSucceedsWithMavenDependencies() throws IOException {
spotless {
java {
target file('test.java')
- googleJavaFormat('1.17.0')
+ googleJavaFormat('%s')
}
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("sub/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
BuildResult result = gradleRunner().withArguments("spotlessApply").build();
@@ -85,15 +87,15 @@ void predeclareFailsWhenDependencyNotPredeclared() throws IOException {
spotless {
java {
target file('test.java')
- googleJavaFormat('1.17.0')
+ googleJavaFormat('%s')
}
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("sub/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
BuildResult result = gradleRunner().withArguments("spotlessApply").buildAndFail();
assertThat(result.getOutput())
- .contains("Add a step with [com.google.googlejavaformat:google-java-format:1.17.0]")
+ .contains("Add a step with [com.google.googlejavaformat:google-java-format:" + GoogleJavaFormatStep.defaultVersion() + "]")
.contains("into the `spotlessPredeclare` block in the root project");
}
@@ -106,9 +108,9 @@ void predeclareWorksWithMultipleVersions() throws IOException {
repositories { mavenCentral() }
spotless { predeclareDeps() }
spotlessPredeclare {
- java { googleJavaFormat('1.17.0') }
+ java { googleJavaFormat('%s') }
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("settings.gradle").toContent("include 'sub1', 'sub2'");
setFile("sub1/build.gradle").toContent("""
plugins {
@@ -118,10 +120,10 @@ void predeclareWorksWithMultipleVersions() throws IOException {
spotless {
java {
target file('test.java')
- googleJavaFormat('1.17.0')
+ googleJavaFormat('%s')
}
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("sub1/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
setFile("sub2/build.gradle").toContent("""
plugins {
@@ -131,10 +133,10 @@ target file('test.java')
spotless {
java {
target file('test.java')
- googleJavaFormat('1.17.0')
+ googleJavaFormat('%s')
}
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("sub2/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
BuildResult result = gradleRunner().withArguments("spotlessApply").build();
@@ -469,11 +471,11 @@ void predeclareWorksWithBothMavenAndP2Dependencies() throws IOException {
spotless { predeclareDeps() }
spotlessPredeclare {
java {
- googleJavaFormat('1.17.0')
+ googleJavaFormat('%s')
eclipse()
}
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("settings.gradle").toContent("include 'sub1', 'sub2'");
setFile("sub1/build.gradle").toContent("""
plugins {
@@ -483,10 +485,10 @@ void predeclareWorksWithBothMavenAndP2Dependencies() throws IOException {
spotless {
java {
target file('test.java')
- googleJavaFormat('1.17.0')
+ googleJavaFormat('%s')
}
}
- """);
+ """.formatted(GoogleJavaFormatStep.defaultVersion()));
setFile("sub1/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
setFile("sub2/build.gradle").toContent("""
plugins {
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/ToggleOffOnTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/ToggleOffOnTest.java
index 3504a70e49..47b69d8217 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/ToggleOffOnTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/ToggleOffOnTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2025 DiffPlug
+ * Copyright 2020-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
+import com.diffplug.spotless.java.GoogleJavaFormatStep;
+
abstract class ToggleOffOnTest extends GradleIntegrationHarness {
private final boolean useConfigCache;
@@ -104,7 +106,7 @@ void gjf() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
- " googleJavaFormat('1.17.0')",
+ " googleJavaFormat('" + GoogleJavaFormatStep.defaultVersion() + "')",
" toggleOffOn()",
" }",
"}");
diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/GitRatchetMavenTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/GitRatchetMavenTest.java
index faedaad602..56bb2e666e 100644
--- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/GitRatchetMavenTest.java
+++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/GitRatchetMavenTest.java
@@ -88,7 +88,7 @@ void singleProjectExhaustiveGlobal() throws Exception {
private void checkBehavior(Git git) throws Exception {
setFile(TEST_PATH).toContent("HELLO");
git.add().addFilepattern(TEST_PATH).call();
- git.commit().setMessage("Initial state").call();
+ git.commit().setSign(false).setMessage("Initial state").call();
// tag this initial state as the baseline for spotless to ratchet from
git.tag().setName("baseline").call();
@@ -165,7 +165,7 @@ void worktreeSupport() throws Exception {
setFile(TEST_PATH).toContent("HELLO");
mainGit.add().addFilepattern(TEST_PATH).call();
- mainGit.commit().setMessage("Initial commit").call();
+ mainGit.commit().setSign(false).setMessage("Initial commit").call();
mainGit.tag().setName("baseline").call();
// Set up a worktree manually (JGit doesn't support worktrees)
diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderRatchetTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderRatchetTest.java
index 24200020f2..917c11688d 100644
--- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderRatchetTest.java
+++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderRatchetTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2024 DiffPlug
+ * Copyright 2020-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,7 +70,7 @@ void normal() throws Exception {
@Test
void ratchetFrom() throws Exception {
try (Git git = Git.init().setDirectory(rootFolder()).call()) {
- git.commit().setMessage("First commit").call();
+ git.commit().setSign(false).setMessage("First commit").call();
}
setRatchetFrom("HEAD");
testSuiteUpdateWithLatest(true);
diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java
index 52e89e58db..0723d73c0e 100644
--- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java
+++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2023 DiffPlug
+ * Copyright 2016-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
import org.junit.jupiter.api.Test;
+import com.diffplug.spotless.java.GoogleJavaFormatStep;
import com.diffplug.spotless.maven.MavenIntegrationHarness;
class GoogleJavaFormatTest extends MavenIntegrationHarness {
@@ -24,7 +25,7 @@ class GoogleJavaFormatTest extends MavenIntegrationHarness {
void specificVersionDefaultStyle() throws Exception {
writePomWithJavaSteps(
"",
- " 1.17.0",
+ " " + GoogleJavaFormatStep.defaultVersion() + "",
"");
runTest("java/googlejavaformat/JavaCodeFormatted.test");
@@ -34,7 +35,7 @@ void specificVersionDefaultStyle() throws Exception {
void specificVersionSpecificStyle() throws Exception {
writePomWithJavaSteps(
"",
- " 1.17.0",
+ " " + GoogleJavaFormatStep.defaultVersion() + "",
" ",
"");
@@ -45,7 +46,7 @@ void specificVersionSpecificStyle() throws Exception {
void specificVersionReflowLongStrings() throws Exception {
writePomWithJavaSteps(
"",
- " 1.17.0",
+ " " + GoogleJavaFormatStep.defaultVersion() + "",
" true",
"");
@@ -56,7 +57,7 @@ void specificVersionReflowLongStrings() throws Exception {
void specificVersionReorderImports() throws Exception {
writePomWithJavaSteps(
"",
- " 1.17.0",
+ " " + GoogleJavaFormatStep.defaultVersion() + "",
" ",
" true",
"");
@@ -68,7 +69,7 @@ void specificVersionReorderImports() throws Exception {
void specificVersionSkipJavadocFormatting() throws Exception {
writePomWithJavaSteps(
"",
- " 1.17.0",
+ " " + GoogleJavaFormatStep.defaultVersion() + "",
" false",
"");
diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/PalantirJavaFormatTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/PalantirJavaFormatTest.java
index eee4fab8c5..0c74450a4e 100644
--- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/PalantirJavaFormatTest.java
+++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/PalantirJavaFormatTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022-2024 DiffPlug
+ * Copyright 2022-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ void specificVersionDefaultStyle() throws Exception {
void specificJava11Version2() throws Exception {
writePomWithJavaSteps(
"",
- " 2.39.0",
+ " 2.80.0",
"");
runTest("java/palantirjavaformat/JavaCodeFormatted.test", "java/palantirjavaformat/JavaCodeUnformatted.test");
@@ -44,7 +44,7 @@ void specificJava11Version2() throws Exception {
void formatJavaDoc() throws Exception {
writePomWithJavaSteps(
"",
- " 2.39.0",
+ " 2.80.0",
" true",
"");
diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java
index dc6e59fef0..3978715d95 100644
--- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java
+++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021-2022 DiffPlug
+ * Copyright 2021-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ void testDiktatWithVersion() throws Exception {
writePomWithKotlinSteps(
"",
- " 1.2.1",
+ " 2.0.0",
"");
String path = "src/main/kotlin/Main.kt";
@@ -56,7 +56,7 @@ void testDiktatConfig() throws Exception {
File conf = setFile(configPath).toResource("kotlin/diktat/diktat-analysis.yml");
writePomWithKotlinSteps(
"",
- " 1.2.1",
+ " 2.0.0",
" " + conf.getAbsolutePath() + "",
"");
diff --git a/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java b/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java
index 4a5f8df9c2..783ca6b94e 100644
--- a/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java
+++ b/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java
@@ -325,6 +325,7 @@ void should_setFromGit_year_when_singleCommit() throws Exception {
.setMessage("add")
.setAuthor("Test User", "test@example.com")
.setCommitter("Test User", "test@example.com")
+ .setSign(false)
.call();
}
diff --git a/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java b/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java
index e9694bbd63..cae19f4bca 100644
--- a/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java
+++ b/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java
@@ -82,7 +82,7 @@ void versionBelowMinOnJava25IsNotAllowed() throws Exception {
FormatterStep step = GoogleJavaFormatStep.create("1.28.0", "AOSP", TestProvisioner.mavenCentral());
StepHarness.forStepNoRoundtrip(step)
.expectLintsOfResource("java/googlejavaformat/JavaCodeWithLicenseUnformatted.test")
- .toBe("LINE_UNDEFINED google-java-format(jvm-version) You are running Spotless on JVM 25. This requires google-java-format of at least 1.30.0 (you are using 1.28.0). (...)");
+ .toBe("LINE_UNDEFINED google-java-format(jvm-version) You are running Spotless on JVM " + Jvm.version() + ". This requires google-java-format of at least 1.30.0 (you are using 1.28.0). (...)");
}
@Test
diff --git a/testlib/src/test/java/com/diffplug/spotless/java/PalantirJavaFormatStepTest.java b/testlib/src/test/java/com/diffplug/spotless/java/PalantirJavaFormatStepTest.java
index a0111ff347..2f37e53326 100644
--- a/testlib/src/test/java/com/diffplug/spotless/java/PalantirJavaFormatStepTest.java
+++ b/testlib/src/test/java/com/diffplug/spotless/java/PalantirJavaFormatStepTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022-2025 DiffPlug
+ * Copyright 2022-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ void behavior() throws Exception {
@Test
void formatJavadoc() throws Exception {
- FormatterStep step = PalantirJavaFormatStep.create("2.57.0", "PALANTIR", true, TestProvisioner.mavenCentral());
+ FormatterStep step = PalantirJavaFormatStep.create(PalantirJavaFormatStep.defaultVersion(), "PALANTIR", true, TestProvisioner.mavenCentral());
StepHarness.forStep(step)
.testResource("java/palantirjavaformat/JavaCodeWithJavaDocUnformatted.test", "java/palantirjavaformat/JavaCodeWithJavaDocFormatted.test")
.testResource("java/palantirjavaformat/JavaCodeWithPackageUnformatted.test", "java/palantirjavaformat/JavaCodeWithPackageFormatted.test");
diff --git a/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java b/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java
index 82180045c6..6efab924ee 100644
--- a/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java
+++ b/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021-2024 DiffPlug
+ * Copyright 2021-2026 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,8 +42,8 @@ void behaviorConf() throws Exception {
File conf = setFile(configPath).toResource("kotlin/diktat/diktat-analysis.yml");
FileSignature config = signAsList(conf);
- FormatterStep step = DiktatStep.create("1.2.1", TestProvisioner.mavenCentral(), config);
- StepHarnessWithFile.forStep(this, step).expectLintsOfResource("kotlin/diktat/Unsolvable.kt").toBe("L1 diktat(diktat-ruleset:debug-print) [DEBUG_PRINT] use a dedicated logging library: found println()",
+ FormatterStep step = DiktatStep.create("2.0.0", TestProvisioner.mavenCentral(), config);
+ StepHarnessWithFile.forStep(this, step).expectLintsOfResource("kotlin/diktat/Unsolvable.kt").toBe("L12 diktat(diktat-ruleset:debug-print) [DEBUG_PRINT] use a dedicated logging library: found println()",
"L13 diktat(diktat-ruleset:debug-print) [DEBUG_PRINT] use a dedicated logging library: found println()");
}
diff --git a/testlib/src/test/java/com/diffplug/spotless/kotlin/KtfmtStepTest.java b/testlib/src/test/java/com/diffplug/spotless/kotlin/KtfmtStepTest.java
index 783b5d50fe..0707a8fa09 100644
--- a/testlib/src/test/java/com/diffplug/spotless/kotlin/KtfmtStepTest.java
+++ b/testlib/src/test/java/com/diffplug/spotless/kotlin/KtfmtStepTest.java
@@ -18,6 +18,8 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledForJreRange;
+import org.junit.jupiter.api.condition.JRE;
import com.diffplug.spotless.FormatterStep;
import com.diffplug.spotless.ResourceHarness;
@@ -79,6 +81,7 @@ void behaviorWithOptions_0_56() {
}
@Test
+ @EnabledForJreRange(max = JRE.JAVA_24)
void dropboxStyle_0_16() throws Exception {
KtfmtStep.KtfmtFormattingOptions options = new KtfmtStep.KtfmtFormattingOptions();
FormatterStep step = KtfmtStep.create("0.16", TestProvisioner.mavenCentral(), KtfmtStep.Style.DROPBOX, options);
@@ -86,6 +89,7 @@ void dropboxStyle_0_16() throws Exception {
}
@Test
+ @EnabledForJreRange(max = JRE.JAVA_24)
void dropboxStyle_0_18() throws Exception {
KtfmtStep.KtfmtFormattingOptions options = new KtfmtStep.KtfmtFormattingOptions();
FormatterStep step = KtfmtStep.create("0.18", TestProvisioner.mavenCentral(), KtfmtStep.Style.DROPBOX, options);
@@ -93,6 +97,7 @@ void dropboxStyle_0_18() throws Exception {
}
@Test
+ @EnabledForJreRange(max = JRE.JAVA_24)
void dropboxStyle_0_22() throws Exception {
KtfmtStep.KtfmtFormattingOptions options = new KtfmtStep.KtfmtFormattingOptions();
FormatterStep step = KtfmtStep.create("0.22", TestProvisioner.mavenCentral(), KtfmtStep.Style.DROPBOX, options);