Skip to content

Commit ae74a21

Browse files
committed
Generate GJF default from version catalog
1 parent dc2a4cb commit ae74a21

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
alias(libs.plugins.buildconfig) apply false
23
alias(libs.plugins.equo.ide)
34
alias(libs.plugins.test.logger) apply false
45
alias(libs.plugins.spotless.changelog) apply false

‎gradle/libs.versions.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ rewrite-recipe-third-party = "org.openrewrite.recipe:rewrite-third-party:0.40.1"
6666
errorprone-core = "com.google.errorprone:error_prone_core:2.42.0"
6767

6868
[plugins]
69+
buildconfig = "com.github.gmazzo.buildconfig:6.0.10"
6970
test-logger = "com.adarshr.test-logger:4.0.0"
7071
spotless = "com.diffplug.spotless:8.10.0"
7172
spotless-changelog = "com.diffplug.spotless-changelog:3.1.2"

‎lib/build.gradle‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ import org.gradle.util.GradleVersion
22

33
plugins {
44
id 'java-library'
5+
id 'com.github.gmazzo.buildconfig'
56
id 'io.github.davidburstrom.version-compatibility'
67
}
78
ext.artifactId = project.artifactIdLib
89
version = rootProject.spotlessChangelog.versionNext
910
apply from: rootProject.file('gradle/java-setup.gradle')
1011
apply from: rootProject.file('gradle/java-publish.gradle')
1112

13+
buildConfig {
14+
packageName('com.diffplug.spotless.java')
15+
useJavaOutput {
16+
defaultVisibility = true
17+
}
18+
buildConfigField(String, 'VERSION_GJF', libs.google.java.format.map {
19+
it.versionConstraint.requiredVersion
20+
})
21+
}
22+
1223
def NEEDS_GLUE = [
1324
// (alphabetic order please)
1425
'cleanthat',

‎lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static FormatterStep createInternally(String name, String groupArtifact,
123123
.addMin(21, "1.17.0") // java 21 requires at least 1.17.0 due to https://github.com/google/google-java-format/issues/898
124124
.addMin(25, "1.30.0") // import module (JEP 511) requires google-java-format >= 1.30.0 (https://github.com/google/google-java-format/issues/1213)
125125
.add(17, "1.28.0") // last version compatible with JDK 17 (1.30.0 references JCAnyPattern, JDK 21+ only)
126-
.add(21, "1.30.0"); // default on JVM 21+ (1.30.0+ handles `import module` in RemoveUnusedImports on JVM 25+)
126+
.add(21, BuildConfig.VERSION_GJF); // default on JVM 21+ (1.30.0+ handles `import module` in RemoveUnusedImports on JVM 25+)
127127

128128
public static String defaultGroupArtifact() {
129129
return MAVEN_COORDINATE;

0 commit comments

Comments
 (0)