Skip to content

Commit 2bf655b

Browse files
committed
Remove GradleCompat and always use project providers for querying properties
1 parent 9d64197 commit 2bf655b

File tree

4 files changed

+7
-47
lines changed

4 files changed

+7
-47
lines changed

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,8 @@ public LicenseHeaderConfig updateYearWithLatest(boolean updateYearWithLatest) {
635635

636636
FormatterStep createStep() {
637637
return builder.withYearModeLazy(() -> {
638-
if (Boolean.parseBoolean(GradleCompat.findOptionalProperty(spotless.project, LicenseHeaderStep.FLAG_SET_LICENSE_HEADER_YEARS_FROM_GIT_HISTORY()))) {
638+
String yearProperty = spotless.project.getProviders().gradleProperty(LicenseHeaderStep.FLAG_SET_LICENSE_HEADER_YEARS_FROM_GIT_HISTORY()).getOrNull();
639+
if (Boolean.parseBoolean(yearProperty)) {
639640
return YearMode.SET_FROM_GIT;
640641
} else {
641642
boolean updateYear = updateYearWithLatest == null ? getRatchetFrom() != null : updateYearWithLatest;

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleCompat.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/IdeHook.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ static class State extends NoLambda.EqualityBasedOnSerialization {
3939
final boolean useStdOut;
4040

4141
State(Project project) {
42-
var pathsString = GradleCompat.findOptionalProperty(project, PROPERTY);
42+
var pathsString = project.getProviders().gradleProperty(PROPERTY).getOrNull();
4343
if (pathsString != null) {
44-
useStdIn = GradleCompat.isPropertyPresent(project, USE_STD_IN);
45-
useStdOut = GradleCompat.isPropertyPresent(project, USE_STD_OUT);
44+
useStdIn = project.getProviders().gradleProperty(USE_STD_IN).isPresent();
45+
useStdOut = project.getProviders().gradleProperty(USE_STD_OUT).isPresent();
4646
paths = Arrays.stream(pathsString.split(","))
4747
.map(String::trim)
4848
.filter(s -> !s.isEmpty())

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 DiffPlug
2+
* Copyright 2016-2026 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ public void apply(Project project) {
4242
+ "https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_cross_compilation");
4343
}
4444
// if -PspotlessModern=true, then use the modern stuff instead of the legacy stuff
45-
if (GradleCompat.isPropertyPresent(project, SPOTLESS_MODERN)) {
45+
if (project.getProviders().gradleProperty(SPOTLESS_MODERN).isPresent()) {
4646
project.getLogger().warn("'spotlessModern' has no effect as of Spotless 5.0, recommend removing it.");
4747
}
4848
// make sure there's a `clean` and a `check`

0 commit comments

Comments
 (0)