Skip to content

Commit e373917

Browse files
committed
Consistently add license header to all java source files
* Add line break after license header to all files, including Kotlin * Add license header to `package-info.java` files
1 parent 200b0ff commit e373917

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

gradle/config/spotless/eclipse-public-license-2.0.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
*
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
10+

gradle/plugins/code-generator/src/main/kotlin/junitbuild/generator/GenerateJreRelatedSourceCode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ abstract class GenerateJreRelatedSourceCode : DefaultTask() {
6464
"allJres" to jres,
6565
"supportedJres" to supportedJres,
6666
"supportedJresSortedByStringValue" to supportedJres.sortedBy { it.version.toString() },
67-
"licenseHeader" to licenseHeaderFile.asFile.get().readText()
67+
"licenseHeader" to licenseHeaderFile.asFile.get().readText().trimEnd() + "\n",
6868
)
6969
templates.forEach {
7070
val targetFile = mainTargetDir.toPath().resolve(it.resolveSibling(it.nameWithoutExtension).path)

gradle/plugins/common/src/main/kotlin/junitbuild.spotless-conventions.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spotless {
3030
val javaFormatterConfigFile = configDir.file("junit-eclipse-formatter-settings.xml")
3131

3232
java {
33-
targetExclude("**/module-info.java")
33+
targetExclude("**/module-info.java", "**/package-info.java")
3434
licenseHeaderFile(license.headerFile, "(package|import) ")
3535
importOrderFile(importOrderConfigFile)
3636
val fullVersion = requiredVersionFromLibs("eclipse")
@@ -41,13 +41,14 @@ spotless {
4141
removeUnusedImports()
4242
}
4343

44-
format("moduleDescriptor") {
44+
format("moduleAndPackageInfo") {
4545
target(fileTree(layout.projectDirectory.dir("src/main/java")) {
46-
include("module-info.java")
46+
include("module-info.java", "**/package-info.java")
4747
})
48-
licenseHeaderFile(license.headerFile, "^$")
48+
licenseHeaderFile(license.headerFile, "((/(//|\\*\\*))|((open )?module )|package|@.+)")
4949
trimTrailingWhitespace()
5050
endWithNewline()
51+
leadingSpacesToTabs()
5152
}
5253
}
5354

platform-tooling-support-tests/platform-tooling-support-tests.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ javaLibrary {
2020
spotless {
2121
java {
2222
target(files(project.java.sourceSets.map { it.allJava }), "projects/**/*.java")
23-
targetExclude("projects/junit-start/**/*.java") // due to compact source files and module imports
23+
fileTree("projects/junit-start") {
24+
include("**/*.java")
25+
}.forEach { file ->
26+
suppressLintsFor { // due to compact source files and module imports
27+
path = file.toRelativeString(project.projectDir)
28+
}
29+
}
30+
}
31+
format("moduleAndPackageInfo") {
32+
target("projects/**/module-info.java", "projects/**/package-info.java")
2433
}
2534
kotlin {
2635
target("projects/**/*.kt")

0 commit comments

Comments
 (0)