Skip to content

Commit 332765a

Browse files
committed
Apply Spotless only in JDK 11+
1 parent 699de9a commit 332765a

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

buildSrc/build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ repositories {
1010
}
1111

1212
dependencies {
13-
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.18.0")
1413
implementation("info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.9.11")
1514
implementation("io.franzbecker:gradle-lombok:5.0.0")
16-
implementation("io.github.cosmicsilence:gradle-scalafix:0.1.14")
15+
16+
// Spotless dropped Java 8 support in version 2.33.0
17+
if (JavaVersion.current().isJava11Compatible) {
18+
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.18.0")
19+
implementation("io.github.cosmicsilence:gradle-scalafix:0.1.14")
20+
}
1721
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
project.apply(plugin: "com.diffplug.spotless")
2+
project.apply(plugin: "io.github.cosmicsilence.scalafix")
3+
4+
spotless {
5+
java {
6+
googleJavaFormat()
7+
}
8+
scala {
9+
scalafmt("2.6.3").configFile(project.rootProject.file("scalafmt.conf"))
10+
}
11+
}
12+
13+
scalafix {
14+
configFile.set(project.rootProject.file("scalafix.conf"))
15+
16+
// Work around dependency resolution issues in April 2022
17+
semanticdb.autoConfigure.set(true)
18+
semanticdb.version.set("4.5.5")
19+
}
20+
21+
project.dependencies.scalafix("com.github.liancheng:organize-imports_2.13:0.6.0")
22+
23+
24+
project.afterEvaluate {
25+
// These need to be in afterEvaluate due to this plugin
26+
// being conditionally applied for Java 11+ only
27+
project.tasks.spotlessApply.configure { dependsOn(project.tasks.scalafix) }
28+
project.tasks.spotlessCheck.configure { dependsOn(project.tasks.checkScalafix) }
29+
30+
// Scalafix adds tasks in afterEvaluate, so their configuration must be deferred
31+
project.tasks.scalafix.finalizedBy(project.tasks.spotlessApply)
32+
project.tasks.checkScalafix.finalizedBy(project.tasks.spotlessCheck)
33+
}
Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
plugins {
2-
id("com.diffplug.spotless")
3-
id("io.github.cosmicsilence.scalafix")
4-
}
5-
6-
spotless {
7-
java {
8-
googleJavaFormat()
9-
}
10-
scala {
11-
scalafmt("2.6.3").configFile(project.rootProject.file("scalafmt.conf"))
12-
}
13-
}
14-
15-
scalafix {
16-
configFile.set(project.rootProject.file("scalafix.conf"))
17-
18-
// Work around dependency resolution issues in April 2022
19-
semanticdb.autoConfigure.set(true)
20-
semanticdb.version.set("4.5.5")
21-
}
22-
23-
project.dependencies.scalafix("com.github.liancheng:organize-imports_2.13:0.6.0")
24-
25-
project.tasks.spotlessApply.configure { dependsOn(project.tasks["scalafix"]) }
26-
project.tasks.spotlessCheck.configure { dependsOn(project.tasks["checkScalafix"]) }
27-
28-
// Scalafix adds tasks in afterEvaluate, so their configuration must be deferred
29-
project.afterEvaluate {
30-
project.tasks["scalafix"].finalizedBy(project.tasks.spotlessApply)
31-
project.tasks["checkScalafix"].finalizedBy(project.tasks.spotlessCheck)
1+
// Spotless dropped Java 8 support in version 2.33.0
2+
if (JavaVersion.current().isJava11Compatible) {
3+
apply(plugin = "project-convention-code-formatting-internal")
324
}

0 commit comments

Comments
 (0)