Skip to content

Commit 5d0fc90

Browse files
committed
Fixup license headers
1 parent d254e67 commit 5d0fc90

File tree

63 files changed

+284
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+284
-56
lines changed

.github/workflows/checkstyle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
distribution: 'graalvm'
2525
java-version: '21'
2626

27-
- run: ./gradlew checkstyle
27+
- run: ./gradlew spotlessCheck checkstyle

build.gradle

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
17
import java.util.concurrent.Executors
28
import java.util.concurrent.TimeUnit
39

@@ -40,6 +46,39 @@ spotless {
4046
.sortByKeys()
4147
.version("2.9.0")
4248
}
49+
java {
50+
target('**/*.java')
51+
targetExclude('metadata/**', '**/build/**', 'gradle/header.java')
52+
// Place header before package/import/module
53+
licenseHeaderFile("$rootDir/gradle/header.java", "package |import |module ")
54+
}
55+
groovy {
56+
target('**/*.groovy')
57+
targetExclude('metadata/**', '**/build/**')
58+
// Place header before package/import
59+
licenseHeaderFile("$rootDir/gradle/header.java", "package |import ")
60+
}
61+
groovyGradle {
62+
// Build scripts (*.gradle)
63+
target('**/*.gradle')
64+
targetExclude('**/build/**', 'gradle/wrapper/**', 'tests/**')
65+
// Insert header at file start (works for any Gradle script layout)
66+
licenseHeaderFile("$rootDir/gradle/header.java", "(?m)^(import\\b|plugins\\b|buildscript\\b|apply\\b|rootProject\\b|pluginManagement\\b|dependencyResolutionManagement\\b)")
67+
}
68+
format('shell') {
69+
target('**/*.sh')
70+
targetExclude('metadata/**', '**/build/**')
71+
// Ensure header appears after shebang if present, else at the very top.
72+
def shHeader = file("$rootDir/gradle/header.sh").text
73+
// If file starts with a shebang and is missing the header, insert it after the shebang
74+
replaceRegex('insert-license-after-shebang',
75+
'(?s)\\A(#!.*\\n)(?!# Copyright and related rights waived via CC0\\n)',
76+
'$1' + shHeader + "\n")
77+
// If file has no shebang and is missing the header, insert it at the start
78+
replaceRegex('insert-license-at-start',
79+
'(?s)\\A(?!#!)(?!# Copyright and related rights waived via CC0\\n)',
80+
shHeader + "\n")
81+
}
4382
}
4483

4584
// gradle package

docs/DEVELOPING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Tip: When debugging locally, add `--stacktrace` for better error output.
3838
```console
3939
./gradlew spotlessCheck
4040
```
41+
3. Auto-fix license headers and formatting locally:
42+
```console
43+
./gradlew spotlessApply
44+
```
45+
Spotless enforces the CC0 license header on Java, Groovy, Gradle build scripts, and shell scripts. The metadata/** directory is excluded from header checks.
4146

4247
### Testing one library locally
4348

@@ -128,6 +133,7 @@ These tasks support the scheduled workflow that checks newer upstream library ve
128133

129134
- Style: `./gradlew checkstyle`
130135
- Format check: `./gradlew spotlessCheck`
136+
- Format apply: `./gradlew spotlessApply`
131137
- Pull images (single lib): `./gradlew pullAllowedDockerImages -Pcoordinates=[group:artifact:version|k/n|all]`
132138
- Check metadata (single lib): `./gradlew checkMetadataFiles -Pcoordinates=[group:artifact:version|k/n|all]`
133139
- Test (single lib): `./gradlew test -Pcoordinates=[group:artifact:version|k/n|all]`

gradle/header.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/

gradle/header.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright and related rights waived via CC0
2+
#
3+
# You should have received a copy of the CC0 legalcode along with this
4+
# work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

settings.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
17
pluginManagement {
28
includeBuild("tests/tck-build-logic")
39
}

tests/src/com.zaxxer/HikariCP/5.0.1/src/test/java/com/zaxxer/hikaricp/test/HikariCPTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* You should have received a copy of the CC0 legalcode along with this
55
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
66
*/
7-
87
package com.zaxxer.hikaricp.test;
98

109
import com.zaxxer.hikari.HikariConfig;

tests/src/com.zaxxer/HikariCP/5.0.1/src/test/java/com/zaxxer/hikaricp/test/driver/CustomConnection.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* You should have received a copy of the CC0 legalcode along with this
55
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
66
*/
7-
87
package com.zaxxer.hikaricp.test.driver;
98

109
import java.sql.Array;

tests/src/com.zaxxer/HikariCP/5.0.1/src/test/java/com/zaxxer/hikaricp/test/driver/CustomDriver.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* You should have received a copy of the CC0 legalcode along with this
55
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
66
*/
7-
87
package com.zaxxer.hikaricp.test.driver;
98

109
import java.sql.Connection;

tests/src/com.zaxxer/HikariCP/6.0.0/src/test/java/com/zaxxer/hikaricp/test/HikariCPTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* You should have received a copy of the CC0 legalcode along with this
55
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
66
*/
7-
87
package com.zaxxer.hikaricp.test;
98

109
import com.zaxxer.hikari.HikariConfig;

0 commit comments

Comments
 (0)