-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
283 lines (244 loc) · 8.05 KB
/
build.gradle
File metadata and controls
283 lines (244 loc) · 8.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
plugins {
id 'io.spring.dependency-management' version '1.1.7'
id 'com.github.ben-manes.versions' version '0.54.0'
id 'java-library'
id 'maven-publish'
id 'signing'
id 'com.vanniktech.maven.publish' version '0.36.0'
id 'net.researchgate.release' version '3.1.0'
id 'checkstyle'
id 'pmd'
id 'jacoco'
}
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
group = 'com.digitalsanctuary.cf.turnstile'
// version '1.1.6-SNAPSHOT'
description = 'SpringBoot Cloudflare Turnstile Library'
ext {
springBootVersion = '4.0.6'
lombokVersion = '1.18.46'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
}
dependencies {
// Spring Boot dependencies
compileOnly "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
compileOnly "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
// Lombok dependencies
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor:$springBootVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
// Lombok dependencies for test classes
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
testAnnotationProcessor "org.springframework.boot:spring-boot-configuration-processor:$springBootVersion"
// Testing dependencies
testImplementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
testImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testImplementation "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
testImplementation 'org.junit.jupiter:junit-jupiter:6.0.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
test {
useJUnitPlatform()
}
tasks.named('jar') {
enabled = true
archiveBaseName.set('ds-spring-cf-turnstile')
archiveClassifier.set('')
}
// Run tests with different JDK versions
tasks.register('testJdk17', Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
useJUnitPlatform()
doFirst {
println("Running tests with JDK 17")
}
}
tasks.register('testJdk21', Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
useJUnitPlatform()
doFirst {
println("Running tests with JDK 21")
}
}
// Task that runs both test tasks
tasks.register('testAll') {
dependsOn(tasks.named('testJdk17'), tasks.named('testJdk21'))
}
// Ensure the default 'test' task triggers both test tasks
tasks.test {
useJUnitPlatform()
dependsOn(tasks.named('testAll'))
}
// Maven Central Publishing Tasks
mavenPublishing {
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
// publishToMavenCentral is now configured via gradle.properties
signAllPublications()
coordinates("com.digitalsanctuary", "ds-spring-cf-turnstile", project.version)
pom {
name = "Spring Cloudflare Turnstile Library"
description = "SpringBoot Cloudflare Turnstile Library"
inceptionYear = "2024"
url = "https://github.com/devondragon/SpringCFTurnstile"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "devondragon"
name = "Devon Hillard"
url = "https://github.com/devondragon/"
}
}
scm {
url = "https://github.com/devondragon/SpringCFTurnstile"
connection = "scm:git:git@github.com:devondragon/SpringCFTurnstile.git"
developerConnection = "scm:git:ssh://git@github.com:devondragon/SpringCFTurnstile.git"
}
}
}
tasks.named("publishMavenPublicationToMavenCentralRepository") {
dependsOn("signMavenPublication")
}
publishing {
repositories {
maven {
name = 'reposiliteRepository'
url = uri('https://reposilite.tr0n.io/private')
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
// more repositories can go here
}
}
// Code Quality Configurations
checkstyle {
// toolVersion = '10.14.2'
configFile = project.file("config/checkstyle/checkstyle.xml")
configProperties = [
'baseDir': rootDir
]
ignoreFailures = true
}
// Skip checkstyle if the config file doesn't exist
tasks.withType(Checkstyle) {
def checkstyleConfigFile = project.file("config/checkstyle/checkstyle.xml")
enabled = checkstyleConfigFile.exists()
if (!checkstyleConfigFile.exists()) {
logger.warn("Checkstyle config file not found at {}, skipping checkstyle tasks", checkstyleConfigFile.absolutePath)
}
}
pmd {
// toolVersion = '6.55.0'
consoleOutput = true
ruleSetFiles = files(project.file("config/pmd/ruleset.xml"))
ruleSets = []
ignoreFailures = true
}
// Skip PMD if the config file doesn't exist
tasks.withType(Pmd) {
def pmdConfigFile = project.file("config/pmd/ruleset.xml")
enabled = pmdConfigFile.exists()
if (!pmdConfigFile.exists()) {
logger.warn("PMD config file not found at {}, skipping PMD tasks", pmdConfigFile.absolutePath)
}
}
jacoco {
// toolVersion = '0.8.11'
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
dependsOn test
}
jacocoTestCoverageVerification {
violationRules {
rule {
enabled = false
limit {
minimum = 0.48
}
}
}
}
// Maven Publishing Aliases
tasks.register("publishReposilite") {
dependsOn("publishMavenPublicationToReposiliteRepository")
}
tasks.register("publishMavenCentral") {
dependsOn("publishAndReleaseToMavenCentral")
// doFirst {
// project.gradle.startParameter.configurationCache = false
// }
}
tasks.register("publishLocal") {
dependsOn("publishToMavenLocal")
// doFirst {
// project.gradle.startParameter.refreshDependencies = true
// }
}
// Debug task to help diagnose file issues in CI
tasks.register("debugCI") {
// Capture values at configuration time to be compatible with configuration cache
def projectDir = project.projectDir.absolutePath
def rootDirectory = rootDir.absolutePath
def checkstyleFile = project.file("config/checkstyle/checkstyle.xml")
def pmdFile = project.file("config/pmd/ruleset.xml")
def configDir = project.file("config")
doLast {
println "Working directory: ${System.getProperty('user.dir')}"
println "Project directory: ${projectDir}"
println "Root directory: ${rootDirectory}"
println "Checkstyle file exists: ${checkstyleFile.exists()}"
if (checkstyleFile.exists()) {
println "Checkstyle file path: ${checkstyleFile.absolutePath}"
}
println "PMD file exists: ${pmdFile.exists()}"
if (pmdFile.exists()) {
println "PMD file path: ${pmdFile.absolutePath}"
}
println "Directory contents:"
configDir.listFiles().each { file ->
println " - ${file.name}"
if (file.isDirectory()) {
file.listFiles().each { subFile ->
println " - ${subFile.name}"
}
}
}
}
}
task generateAIChangelog(type: Exec) {
def newVersion = project.version
commandLine 'mise', 'x', '--', 'python', 'generate_changelog.py', newVersion
}
release {
beforeReleaseBuild.dependsOn generateAIChangelog
// afterReleaseBuild.dependsOn publishReposilite
afterReleaseBuild.dependsOn publishMavenCentral
}