Skip to content

Commit a6c23e5

Browse files
authored
build: Use spotless for license header checks (#38)
1 parent daf19ea commit a6c23e5

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

build.gradle.kts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import com.diffplug.gradle.spotless.SpotlessExtension
12
import net.kyori.indra.IndraExtension
23
import net.kyori.indra.gradle.IndraPluginPublishingExtension
3-
import org.cadixdev.gradle.licenser.LicenseExtension
44

55
plugins {
66
id("com.gradle.plugin-publish") apply false
77
id("net.kyori.indra") apply false
8-
id("net.kyori.indra.license-header") apply false
8+
id("com.diffplug.spotless") apply false
99
id("net.kyori.indra.publishing.gradle-plugin") apply false
1010
}
1111

@@ -17,7 +17,7 @@ subprojects {
1717
apply(JavaGradlePluginPlugin::class)
1818
apply("com.gradle.plugin-publish")
1919
apply("net.kyori.indra")
20-
apply("net.kyori.indra.license-header")
20+
apply("com.diffplug.spotless")
2121
apply("net.kyori.indra.publishing.gradle-plugin")
2222
apply("net.kyori.indra.git")
2323
}
@@ -77,17 +77,28 @@ subprojects {
7777
}
7878
}
7979

80-
extensions.configure(LicenseExtension::class) {
80+
extensions.configure(SpotlessExtension::class) {
8181
val name: String by project
8282
val organization: String by project
8383
val projectUrl: String by project
8484

85-
properties {
86-
this["name"] = name
87-
this["organization"] = organization
88-
this["url"] = projectUrl
85+
java {
86+
val lineSep = System.lineSeparator()
87+
val contents = rootProject.file("HEADER.txt")
88+
.readLines().asSequence()
89+
.map { (" * " + it).trimEnd() }
90+
.joinToString(prefix = "/*${lineSep}", postfix = "${lineSep} */", separator = lineSep)
91+
92+
val formattedContents = groovy.text.SimpleTemplateEngine()
93+
.createTemplate(contents)
94+
.make(mutableMapOf(
95+
"name" to name,
96+
"organization" to organization,
97+
"url" to projectUrl
98+
))
99+
100+
licenseHeader(formattedContents.toString())
89101
}
90-
header(rootProject.file("HEADER.txt"))
91102
}
92103

93104
extensions.configure(SigningExtension::class) {

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pluginManagement {
88
plugins {
99
val indraVersion = "2.1.1"
1010
id("com.gradle.plugin-publish") version "0.21.0"
11+
id("com.diffplug.spotless") version "6.5.2"
1112
id("net.kyori.indra") version indraVersion
12-
id("net.kyori.indra.license-header") version indraVersion
1313
id("net.kyori.indra.publishing.gradle-plugin") version indraVersion
1414
}
1515
}

0 commit comments

Comments
 (0)