Skip to content

Commit c764277

Browse files
committed
style: generate dynamic license header
1 parent 98d2ed4 commit c764277

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

LICENSE-HEADER.txt

-16
This file was deleted.

build.gradle.kts

+33-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ subprojects {
3636
configure<app.cash.licensee.LicenseeExtension> {
3737
ignoreDependencies("plus.sourceplus", "protocol")
3838
ignoreDependencies("plus.sourceplus", "protocol-jvm")
39+
ignoreDependencies("plus.sourceplus.interface", "interface-booster-ui")
3940
allow("Apache-2.0")
4041
allow("MIT")
4142
allow("EPL-1.0")
@@ -95,11 +96,40 @@ subprojects {
9596
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
9697
kotlin {
9798
targetExclude("**/generated/**", "**/liveplugin/**")
98-
if (file("../LICENSE-HEADER.txt").exists()) {
99-
licenseHeaderFile(file("../LICENSE-HEADER.txt"))
99+
100+
val startYear = 2022
101+
val currentYear = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR)
102+
val copyrightYears = if (startYear == currentYear) {
103+
"$startYear"
100104
} else {
101-
licenseHeaderFile(file("../../LICENSE-HEADER.txt"))
105+
"$startYear-$currentYear"
106+
}
107+
108+
val jetbrainsProject = findProject(":interfaces:jetbrains") ?: rootProject
109+
val licenseHeader = Regex("( . Copyright [\\S\\s]+)")
110+
.find(File(jetbrainsProject.projectDir, "LICENSE").readText())!!
111+
.value.lines().joinToString("\n") {
112+
if (it.trim().isEmpty()) {
113+
" *"
114+
} else {
115+
" * " + it.trim()
116+
}
117+
}
118+
val formattedLicenseHeader = buildString {
119+
append("/*\n")
120+
append(
121+
licenseHeader.replace(
122+
"Copyright [yyyy] [name of copyright owner]",
123+
"Source++, the open-source live coding platform.\n" +
124+
" * Copyright (C) $copyrightYears CodeBrig, Inc."
125+
).replace(
126+
"http://www.apache.org/licenses/LICENSE-2.0",
127+
" http://www.apache.org/licenses/LICENSE-2.0"
128+
)
129+
)
130+
append("/")
102131
}
132+
licenseHeader(formattedLicenseHeader)
103133
}
104134
}
105135
}

0 commit comments

Comments
 (0)