Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();

@Goooler Goooler Sep 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes test failures on my machines like, as I enabled commit.gpgsign in ~/.gitconfig.

}
}
5 changes: 5 additions & 0 deletions lib/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
<Match>
<Bug pattern="USO_UNSAFE_STATIC_METHOD_SYNCHRONIZATION"/>
</Match>
<Match>
<!-- Process implements AutoCloseable on Java 24+, but not on Java 17 -->
<Class name="com.diffplug.spotless.ProcessRunner$LongRunningProcess"/>
<Bug pattern="RI_REDUNDANT_INTERFACES"/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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(
Expand All @@ -31,7 +35,7 @@ void integration() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
" googleJavaFormat('1.17.0')",
" googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
" }",
"}");

Expand All @@ -41,7 +45,7 @@ void integration() throws IOException {

checkRunsThenUpToDate();
replace("build.gradle",
"googleJavaFormat('1.17.0')",
"googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
"googleJavaFormat()");
checkRunsThenUpToDate();
}
Expand All @@ -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)",
" }",
"}");

Expand All @@ -67,7 +71,7 @@ void integrationWithReorderImports() throws IOException {

checkRunsThenUpToDate();
replace("build.gradle",
"googleJavaFormat('1.17.0')",
"googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
"googleJavaFormat()");
checkRunsThenUpToDate();
}
Expand All @@ -83,7 +87,7 @@ void integrationWithSkipJavadocFormatting() throws IOException {
"spotless {",
" java {",
" target file('test.java')",
" googleJavaFormat('1.17.0').skipJavadocFormatting()",
" googleJavaFormat('" + NON_DEFAULT_VERSION + "').skipJavadocFormatting()",
" }",
"}");

Expand All @@ -93,7 +97,7 @@ void integrationWithSkipJavadocFormatting() throws IOException {

checkRunsThenUpToDate();
replace("build.gradle",
"googleJavaFormat('1.17.0')",
"googleJavaFormat('" + NON_DEFAULT_VERSION + "')",
"googleJavaFormat()");
checkRunsThenUpToDate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand All @@ -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() }",
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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() }",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'");
Expand Down
Loading
Loading