-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
290 lines (266 loc) · 8.96 KB
/
build.gradle
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
//file:noinspection DependencyNotationArgument
plugins {
id 'java'
id 'checkstyle'
id 'jacoco'
id 'maven-publish'
id 'signing'
alias(libs.plugins.lombok)
alias(libs.plugins.versioner)
alias(libs.plugins.index.scan)
alias(libs.plugins.owasp.dependencycheck)
alias(libs.plugins.cyclonedx.bom)
alias(libs.plugins.licensee.plugin)
alias(libs.plugins.nexus.publish.plugin)
}
group = 'com.github.nagyesta'
apply from: "config/ossindex/ossIndexAudit.gradle"
project.ext {
gitToken = project.hasProperty('githubToken') ? (project.property('githubToken') as String) : ''
gitUser = project.hasProperty('githubUser') ? (project.property('githubUser') as String) : ''
ossrhUser = project.hasProperty('ossrhUsername') ? (project.property('ossrhUsername') as String) : ''
ossrhPass = project.hasProperty('ossrhPassword') ? (project.property('ossrhPassword') as String) : ''
ossIndexUser = project.hasProperty('ossIndexUsername') ? (project.property('ossIndexUsername') as String) : ''
ossIndexPass = project.hasProperty('ossIndexPassword') ? (project.property('ossIndexPassword') as String) : ''
artifactDisplayName = "Cache-Only"
artifactDescription = "Cache-Only is a minimal library augmenting the Spring cache abstraction with a way for caching bulk API calls."
repoUrl = 'https://github.com/nagyesta/cache-only'
licenseName = 'MIT License'
licenseUrl = 'https://raw.githubusercontent.com/nagyesta/cache-only/main/LICENSE'
maintainerId = 'nagyesta'
maintainerName = 'Istvan Zoltan Nagy'
maintainerUrl = 'https://github.com/nagyesta/'
scmConnection = 'scm:git:https://github.com/nagyesta/cache-only.git'
scmProjectUrl = 'https://github.com/nagyesta/cache-only/'
}
versioner {
startFrom {
major = 0
minor = 0
patch = 1
}
match {
major = '{major}'
minor = '{minor}'
patch = '{patch}'
}
pattern {
pattern = "%M.%m.%p"
}
git {
authentication {
https {
token = project.ext.gitToken
}
}
}
tag {
prefix = 'v'
useCommitMessage = true
}
}
versioner.apply()
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_17
withJavadocJar()
withSourcesJar()
}
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
dependencies {
annotationProcessor libs.lombok
compileOnly libs.jetbrains.annotations
testCompileOnly libs.jetbrains.annotations
implementation libs.slf4j.api
implementation libs.commons.collections4
implementation libs.spring.context.support
testImplementation libs.jupiter.core
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation libs.mockito.core
testImplementation libs.spring.test
testImplementation libs.spring.context.support
testImplementation libs.logback.classic
}
cyclonedxBom {
includeConfigs = ["runtimeClasspath"]
skipConfigs = ["compileClasspath", "testCompileClasspath"]
skipProjects = []
projectType = "library"
schemaVersion = "1.5"
destination = file("build/reports")
outputName = "bom"
outputFormat = "json"
//noinspection UnnecessaryQualifiedReference
final def attachmentText = new org.cyclonedx.model.AttachmentText()
attachmentText.setText(file("LICENSE").readBytes().encodeBase64().toString())
attachmentText.setEncoding("base64")
attachmentText.setContentType("text/plain")
//noinspection UnnecessaryQualifiedReference
final def license = new org.cyclonedx.model.License()
license.setName(project.ext.licenseName)
license.setLicenseText(attachmentText)
license.setUrl(project.ext.licenseUrl)
setLicenseChoice {
it.addLicense(license)
}
}
licensee {
allow("Apache-2.0")
allow("MIT")
}
tasks.register('copyLegalDocs', Copy.class) {
from file("${projectDir}/LICENSE")
from layout.buildDirectory.file("reports/licensee/artifacts.json").get().asFile
from layout.buildDirectory.file("reports/bom.json").get().asFile
into layout.buildDirectory.dir("resources/main/META-INF").get().asFile
rename('artifacts.json', 'dependency-licenses.json')
rename('bom.json', 'SBOM.json')
}
tasks.copyLegalDocs.dependsOn(tasks.licensee)
tasks.copyLegalDocs.dependsOn(tasks.cyclonedxBom)
tasks.javadoc.dependsOn(tasks.copyLegalDocs)
tasks.compileTestJava.dependsOn(tasks.copyLegalDocs)
tasks.checkstyleMain.dependsOn(tasks.copyLegalDocs)
tasks.processResources.finalizedBy(tasks.copyLegalDocs)
jacocoTestReport {
reports {
xml.required.set(true)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/report.xml").get().asFile)
csv.required.set(false)
html.required.set(true)
html.outputLocation.set(layout.buildDirectory.dir("reports/jacoco/html").get().asFile)
}
}
test {
useJUnitPlatform()
}
test.finalizedBy jacocoTestReport
jacocoTestReport.finalizedBy jacocoTestCoverageVerification
jacoco {
toolVersion = libs.versions.jacoco.get()
}
jacocoTestCoverageVerification {
inputs.file(layout.buildDirectory.file("reports/jacoco/report.xml").get().asFile)
outputs.file(layout.buildDirectory.file("reports/jacoco/jacocoTestCoverageVerification").get().asFile)
violationRules {
rule {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.8
}
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.8
}
excludes = [
]
}
rule {
element = 'CLASS'
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.5
}
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.5
}
excludes = [
"com.github.nagyesta.cacheonly.raw.BatchServiceCaller",
"com.github.nagyesta.cacheonly.transform.NoOpPartialCacheSupport"
]
}
}
doLast {
layout.buildDirectory.file("reports/jacoco/jacocoTestCoverageVerification").get().asFile.write("Passed")
}
}
jar.dependsOn check
tasks.withType(Checkstyle).configureEach {
configProperties = [base_dir: rootDir.toString(), cache_file: layout.buildDirectory.file("checkstyle/cacheFile").get().asFile]
reports {
xml.required.set(false)
html.required.set(true)
html.stylesheet resources.text
.fromFile(rootProject.file('config/checkstyle/checkstyle-stylesheet.xsl') as String)
}
}
checkstyle.toolVersion = libs.versions.checkstyle.get()
nexusPublishing {
repositories {
sonatype {
username = project.ext.ossrhUser
password = project.ext.ossrhPass
}
}
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/nagyesta/cache-only")
credentials {
username = project.ext.gitUser
password = project.ext.gitToken
}
}
}
publications {
//noinspection GroovyAssignabilityCheck
mavenJava(MavenPublication) {
from components.java
artifactId = "${project.name}"
pom {
name = "${project.artifactDisplayName}"
description = "${project.artifactDescription}"
url = project.ext.repoUrl
licenses {
license {
name = project.ext.licenseName
url = project.ext.licenseUrl
}
}
developers {
developer {
id = project.ext.maintainerId
name = project.ext.maintainerName
url = project.ext.maintainerUrl
}
}
scm {
connection = project.ext.scmConnection
developerConnection = project.ext.scmConnection
url = project.ext.scmProjectUrl
}
withXml {
//noinspection GroovyImplicitNullArgumentCall
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime'
}.each { it.scope*.value = 'compile' }
}
}
}
}
}
//Disable metadata publishing and rely on Maven only
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
ossIndexAudit {
username = rootProject.ext.ossIndexUser
password = rootProject.ext.ossIndexPass
printBanner = false
colorEnabled = true
showAll = false
outputFormat = 'DEPENDENCY_GRAPH'
excludeVulnerabilityIds = rootProject.ext.ossIndexExclusions
}
signing {
sign publishing.publications.mavenJava
}