-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
351 lines (311 loc) · 13.7 KB
/
build.gradle
File metadata and controls
351 lines (311 loc) · 13.7 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
plugins {
id 'org.springframework.boot' version '4.0.4'
id 'io.spring.dependency-management' version '1.1.7'
id 'java-library'
id 'maven-publish'
id 'com.adarshr.test-logger' version '4.0.0'
id 'jacoco'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id "org.flywaydb.flyway" version "11.20.3"
id "com.github.jk1.dependency-license-report" version "3.1.1"
}
tasks.withType(Jar).configureEach {
zip64 = true
}
subprojects {
tasks.withType(Jar).configureEach {
zip64 = true
}
}
jacoco {
toolVersion = '0.8.10'
}
group = "org.codeforamerica.platform"
version = "4.0.4-SNAPSHOT"
ext.admin = System.getenv("SONATYPE_USERNAME")
def localEnv = new Properties()
if (file(".env").isFile()) {
file(".env").withInputStream { localEnv.load(it) }
}
def sonatypeUsername = localEnv.getProperty("SONATYPE_USERNAME") ?: System.getenv("SONATYPE_USERNAME")
def sonatypePassword = localEnv.getProperty("SONATYPE_PASSWORD") ?: System.getenv("SONATYPE_PASSWORD")
jar {
zip64 = true
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes('Main-Class': 'formflow.library.ScreenController')
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
bootJar {
enabled = false
}
tasks.register('webjar', Jar) {
zip64 = true
from(fileTree("dist")) {
into "META-INF/resources"
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
api 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.integration:spring-integration-ws:7.0.4'
implementation 'com.google.guava:guava:33.5.0-jre'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.jetbrains:annotations:26.1.0'
implementation 'io.hypersistence:hypersistence-utils-hibernate-71:3.15.2'
implementation 'org.flywaydb:flyway-core:11.20.3'
implementation "org.flywaydb:flyway-database-postgresql:11.20.3"
implementation 'org.webjars.npm:dropzone:5.9.3'
implementation 'software.amazon.awssdk:s3:2.42.21'
implementation 'com.smartystreets.api:smartystreets-java-sdk:5.4.0'
implementation 'com.github.librepdf:openpdf:3.0.3'
implementation 'org.yaml:snakeyaml:2.6'
implementation 'com.google.crypto.tink:tink:1.21.0'
implementation 'org.springframework.session:spring-session-jdbc'
implementation 'org.apache.tika:tika-core:3.3.0'
implementation 'commons-codec:commons-codec:1.21.0'
implementation 'org.apache.commons:commons-text:1.15.0'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter:6.0.3'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testImplementation 'org.springframework.boot:spring-boot-starter-flyway'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.jsoup:jsoup:1.22.1'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'io.github.bonigarcia:webdrivermanager:6.3.3'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.seleniumhq.selenium:selenium-java'
testImplementation 'org.postgresql:postgresql'
testImplementation 'org.projectlombok:lombok:1.18.44'
testImplementation 'com.squareup.okhttp3:mockwebserver:5.3.2'
testImplementation 'org.bouncycastle:bcpkix-jdk18on:1.83'
}
test {
finalizedBy jacocoTestReport
useJUnitPlatform()
maxParallelForks = 1 // Run tests sequentially to avoid connection exhaustion
}
jacocoTestReport {
reports {
xml.required = true
}
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withJavadocJar()
withSourcesJar()
}
tasks.named('bootJar').configure {
enabled = false
}
publishing {
publications {
pluginMaven(MavenPublication) {
artifactId = "form-flow"
artifact(tasks.named("jar").get().archiveFile)
artifact tasks.javadocJar
artifact tasks.sourcesJar
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
pom {
name = "Form Flow Builder"
description = "A Java library placed in a Spring Boot app to generate form flows."
url = "https://github.com/codeforamerica/form-flow/"
licenses {
license {
name = 'MIT License'
url = 'https://raw.githubusercontent.com/git/git-scm.com/main/MIT-LICENSE.txt'
}
}
developers {
developer { id = 'birdprsn'; name = 'Alex Gonzalez'; email = 'agonzalez@codeforamerica.org' }
developer { id = 'amedrano'; name = 'Ana Medrano'; email = 'amedrano@codeforamerica.org' }
developer { id = 'mperlman'; name = 'Marc Perlman'; email = 'mperlman@codeforamerica.org' }
developer { id = 'cenyia'; name = 'Chibuisi Enyia'; email = 'cenyia@codeforamerica.org' }
developer { id = 'mtodd'; name = 'Morgan Todd'; email = 'mtodd@codeforamerica.org' }
}
scm { url = 'scm:git:https://github.com/codeforamerica/form-flow.git' }
}
}
}
}
signing {
required = admin
def signingKey = System.getenv("GPG_SIGNING_KEY")
def signingPassword = System.getenv("GPG_SIGNING_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
}
nexusPublishing {
repositories {
sonatype {
if (version.endsWith("-SNAPSHOT")) {
println("Using a SNAPSHOT: ${version}")
} else {
println("Using a release version: ${version}")
}
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
username = sonatypeUsername
password = sonatypePassword
}
}
}
javadoc {
options.addStringOption('Xmaxwarns', '1000')
}
configurations {
licenseReportDependencies {
canBeResolved = true
canBeConsumed = false
extendsFrom configurations.implementation
extendsFrom configurations.api
extendsFrom configurations.testImplementation
extendsFrom configurations.compileOnly
extendsFrom configurations.annotationProcessor
}
}
licenseReport {
configurations = ['licenseReportDependencies']
outputDir = file("${buildDir}/license-report")
renderers = [ new com.github.jk1.license.render.CsvReportRenderer() ]
}
// Safe license-report post-processing for Gradle 9.2+
afterEvaluate {
def licenseTasks = tasks.matching { it.name == "licenseReport" || it.name == "generateLicenseReport" }
if (!licenseTasks.isEmpty()) {
licenseTasks.configureEach { licenseTask ->
licenseTask.doLast {
def csvFile = file("${buildDir}/license-report/licenses.csv")
if (!csvFile.exists()) {
println "No license report found."
return
}
def directDeps = configurations.runtimeClasspath
.resolvedConfiguration
.firstLevelModuleDependencies
.collect { "${it.moduleGroup}:${it.moduleName}:${it.moduleVersion}" }
.toSet()
def normalizeLicense = { license ->
switch (license.trim()) {
case "Apache License 2.0":
case "Apache 2.0":
case "Apache-2.0":
case "The Apache License, Version 2.0":
case "Apache License, Version 2.0":
case "The Apache Software License, Version 2.0":
return "Apache 2.0"
case "MIT License":
case "The MIT License (MIT)":
case "The MIT License":
case "MIT":
return "MIT"
case "GNU Lesser General Public License":
case "GNU Lesser General Public License v3.0 or later":
return "LGPL"
case "GNU General Public License, version 2 with the GNU Classpath Exception":
case "GPL2 w/ CPE":
return "GPL"
case "Eclipse Public License v2.0":
case "Eclipse Public License 1.0":
return "EPL"
case "Mozilla Public License, Version 2.0":
case "MPL 2.0":
return "MPL"
case "Public Domain, per Creative Commons CC0":
return "Public Domain per Creative Commons CC0"
default:
return license.replaceAll(",", "")
}
}
def directByLicense = [:].withDefault { [] }
def transitiveByLicense = [:].withDefault { [] }
def allDeps = []
csvFile.eachLine { line ->
if (!line.toLowerCase().startsWith("artifact") && line.trim()) {
def parts = line.split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/)
def library = parts.length > 0 ? parts[0].replaceAll(/^"|"$/, "") : "unknown"
def license = parts.length > 2 ? parts[2].replaceAll(/^"|"$/, "") : "unknown"
if (library == "artifact" && license == "moduleLicense") return
license = normalizeLicense(license)
def isDirect = directDeps.any { dep ->
def depShort = dep.substring(0, dep.lastIndexOf(':'))
library.startsWith(depShort)
}
def scope = isDirect ? "direct" : "transitive"
def (group, name, version) = library.tokenize(':')
group = group ?: ""
name = name ?: ""
version = version ?: ""
allDeps << [
coordinate: "${group}:${name}:${version}",
group : group,
name : name,
version : version,
license : license ?: "unknown",
scope : scope
]
if (isDirect) {
directByLicense[license] << library
} else {
transitiveByLicense[license] << library
}
}
}
def printGrouped = { title, map ->
println "\n📦 ${title}:"
map.sort { -it.value.size() }.each { license, libs ->
println "\"${license}\",${libs.size()}"
libs.sort().each { lib ->
println " - ${lib}"
}
println ""
}
}
printGrouped("DIRECT DEPENDENCIES", directByLicense)
printGrouped("TRANSITIVE DEPENDENCIES", transitiveByLicense)
println "\n✅ Total: ${directByLicense.values().sum { it.size() }} direct, ${transitiveByLicense.values().sum { it.size() }} transitive"
def outputCsv = file("${buildDir}/license-report/licenses_detailed.csv")
outputCsv.withPrintWriter { pw ->
pw.println('"coordinate","package","name","version","license","scope"')
allDeps.sort { a, b ->
def scopeOrder = ["direct": 0, "transitive": 1]
def c1 = scopeOrder[a.scope] <=> scopeOrder[b.scope]
if (c1 != 0) return c1
def c2 = a.license <=> b.license
if (c2 != 0) return c2
def c3 = a.group <=> b.group
if (c3 != 0) return c3
return a.name <=> b.name
}.each { dep ->
def csvLine = [dep.coordinate, dep.group, dep.name, dep.version, dep.license, dep.scope]
.collect { "\"${it.replaceAll('"', '""')}\"" }
.join(',')
pw.println(csvLine)
}
}
println "\n📝 Wrote detailed CSV with coordinates: ${outputCsv.absolutePath}"
}
}
} else {
logger.warn("⚠️ License report task not found; skipping post-processing")
}
}