Skip to content

Commit 484303e

Browse files
authored
refactor: remove license header file (#108)
fixes sourceplusplus/sourceplusplus#600
1 parent 3e35e57 commit 484303e

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

LICENSE-HEADER.txt

-16
This file was deleted.

build.gradle.kts

+33-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,39 @@ subprojects {
2626
apply(plugin = "com.diffplug.spotless")
2727
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
2828
kotlin {
29-
licenseHeaderFile(file("../LICENSE-HEADER.txt"))
29+
val startYear = 2022
30+
val currentYear = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR)
31+
val copyrightYears = if (startYear == currentYear) {
32+
"$startYear"
33+
} else {
34+
"$startYear-$currentYear"
35+
}
36+
37+
val probeProject = findProject(":probes:jvm") ?: rootProject
38+
val licenseHeader = Regex("( . Copyright [\\S\\s]+)")
39+
.find(File(probeProject.projectDir, "LICENSE").readText())!!
40+
.value.lines().joinToString("\n") {
41+
if (it.trim().isEmpty()) {
42+
" *"
43+
} else {
44+
" * " + it.trim()
45+
}
46+
}
47+
val formattedLicenseHeader = buildString {
48+
append("/*\n")
49+
append(
50+
licenseHeader.replace(
51+
"Copyright [yyyy] [name of copyright owner]",
52+
"Source++, the open-source live coding platform.\n" +
53+
" * Copyright (C) $copyrightYears CodeBrig, Inc."
54+
).replace(
55+
"http://www.apache.org/licenses/LICENSE-2.0",
56+
" http://www.apache.org/licenses/LICENSE-2.0"
57+
)
58+
)
59+
append("/")
60+
}
61+
licenseHeader(formattedLicenseHeader)
3062
}
3163
}
3264
}

0 commit comments

Comments
 (0)