-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
321 lines (291 loc) · 8.67 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
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
plugins {
id 'java'
id 'java-library'
id 'java-gradle-plugin'
id 'groovy'
id 'idea'
id 'checkstyle'
id 'pmd'
id 'jacoco'
id 'maven-publish'
id 'signing'
id 'project-report'
id 'build-dashboard'
id 'com.gradle.plugin-publish' version '1.2.0'
id 'com.github.spotbugs' version '5.0.14'
id 'org.owasp.dependencycheck' version '8.2.1'
id 'org.sonarqube' version '4.2.0.3129'
}
def javaVersion = JavaVersion.VERSION_17
wrapper {
gradleVersion = '8.1.1'
distributionType = Wrapper.DistributionType.BIN
distributionSha256Sum = 'e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f'
}
repositories {
mavenCentral()
mavenLocal()
}
java {
sourceCompatibility = javaVersion
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
}
jar {
def manifestAttributes = [
'Created-By' : "Gradle ${project.gradle.gradleVersion}",
'Specification-Title' : "${project.description}",
'Specification-Version' : "${project.version}",
'Specification-Vendor' : "${project.property('author')} <${project.property('email')}>",
'Implementation-Title' : "${project.description}",
'Implementation-Version' : "${project.version}",
'Implementation-Vendor' : "${project.property('author')} <${project.property('email')}>",
'Implementation-Vendor-Id': "${project.property('author')} <${project.property('email')}>",
]
manifest {
attributes(manifestAttributes)
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
project {
vcs = 'Git'
jdkName = "jdk-${javaVersion}"
languageLevel = JavaVersion.VERSION_1_8
}
}
checkstyle {
toolVersion = property('checkstyleVersion')
ignoreFailures = false
}
pmd {
consoleOutput = true
incrementalAnalysis = true
toolVersion = property('pmdVersion')
ignoreFailures = false
ruleSets = []
ruleSetConfig = resources.text.fromFile('config/pmd/pmd-rules.xml')
}
spotbugs {
toolVersion = property('spotbugsVersion')
ignoreFailures = false
effort = 'max'
reportLevel = 'low'
//noinspection GroovyAssignabilityCheck
excludeFilter = rootProject.file('config/spotbugs/excludeFilter.xml')
}
spotbugsMain {
reports {
html {
outputLocation = project.layout.buildDirectory.file('reports/spotbugs/main/spotbugs.html').get().asFile
stylesheet = 'fancy-hist.xsl'
}
xml {
outputLocation = project.layout.buildDirectory.file('reports/spotbugs/main/spotbugs.xml').get().asFile
}
}
}
spotbugsTest.enabled = false
jacoco {
toolVersion = property('jacocoVersion')
}
jacocoTestReport {
dependsOn project.tasks.test
reports {
xml.required = true
csv.required = false
html.required = true
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = 'INSTRUCTION'
minimum = 0.7
}
limit {
counter = 'BRANCH'
minimum = 0.7
}
limit {
counter = 'LINE'
minimum = 0.7
}
limit {
counter = 'METHOD'
minimum = 0.7
}
limit {
counter = 'CLASS'
minimum = 0.7
}
}
}
}
dependencyCheck {
autoUpdate = true
failBuildOnCVSS = 1
cveValidForHours = 1
format = 'ALL'
outputDirectory = project.layout.buildDirectory.dir('reports/dependency-check').get().asFile
suppressionFile = project.rootProject.file('config/dependency-check/suppressions.xml')
//noinspection GroovyAssignabilityCheck
analyzers {
experimentalEnabled = true
archiveEnabled = true
jarEnabled = true
centralEnabled = true
nexusEnabled = false
nexusUsesProxy = false
nuspecEnabled = false
assemblyEnabled = false
msbuildEnabled = false
golangDepEnabled = false
golangModEnabled = false
cocoapodsEnabled = false
swiftEnabled = false
swiftPackageResolvedEnabled = false
bundleAuditEnabled = false
pyDistributionEnabled = false
pyPackageEnabled = false
rubygemsEnabled = false
opensslEnabled = false
cmakeEnabled = false
autoconfEnabled = false
composerEnabled = false
cpanEnabled = false
nodeEnabled = false
}
}
publishing {
publications {
//noinspection GroovyAssignabilityCheck
mavenJava(MavenPublication) {
//noinspection GroovyAssignabilityCheck
from project.components.java
pom {
//noinspection GroovyAssignabilityCheck
name = project.name
description = project.description
//noinspection GroovyAssignabilityCheck
url = project.property('url')
licenses {
//noinspection GroovyAssignabilityCheck
license {
//noinspection GroovyAssignabilityCheck
name = project.property('license')
//noinspection GroovyAssignabilityCheck
url = project.property('licenseUrl')
}
}
developers {
developer {
//noinspection GroovyAssignabilityCheck
id = project.property('authorId')
//noinspection GroovyAssignabilityCheck
name = project.property('author')
//noinspection GroovyAssignabilityCheck
email = project.property('email')
}
}
scm {
//noinspection GroovyAssignabilityCheck
connection = "scm:git:git://${project.property('scmUrl')}"
//noinspection GroovyAssignabilityCheck
developerConnection = "scm:git:ssh://${project.property('scmUrl')}"
//noinspection GroovyAssignabilityCheck
url = project.property('url')
}
}
}
}
repositories {
if (System.getenv('CI') == 'true') {
maven {
name = 'GitHubPackages'
url = property('ghpUrl')
credentials {
username = System.getenv('GITHUB_ACTOR')
password = System.getenv('GITHUB_TOKEN')
}
}
} else {
maven {
url = project.layout.buildDirectory.dir('repos')
}
}
}
}
signing {
if (System.getenv('GPG_KEY_ID') && System.getenv('GPG_KEY') && System.getenv('GPG_PASSPHRASE')) {
useInMemoryPgpKeys(System.getenv('GPG_KEY_ID'), System.getenv('GPG_KEY'), System.getenv('GPG_PASSPHRASE'))
sign publishing.publications
}
}
gradlePlugin {
website = 'https://github.com/gregoranders/gradle-project-configuration'
vcsUrl = 'https://github.com/gregoranders/gradle-project-configuration'
plugins {
projectConfigurationPlugin {
id = 'io.github.gregoranders.project-configuration'
implementationClass = 'io.github.gregoranders.gradle.project.ProjectConfigurationPlugin'
displayName = project.property('pluginDisplayName')
description = project.property('pluginDescription')
tags.set(['project', 'configuration', 'java', 'checkstyle', 'pmd', 'spotbugs', 'jacoco', 'dependencycheck'])
}
}
}
test {
doFirst {
def version = project.extensions.findByType(JacocoPluginExtension.class).toolVersion
def configuration = configurations.create('jacocoRuntime').setVisible(false).setDescription('JaCoCo agent runtime')
configuration.dependencies.add(project.dependencies.create("org.jacoco:org.jacoco.agent:$version:runtime"))
def runtimeAsFile = project.configurations.jacocoRuntime.resolve()[0]
//noinspection GroovyAssignabilityCheck
def jvmArgs = "-javaagent:${runtimeAsFile}=destfile=${project.layout.buildDirectory.file('jacoco/test.exec').get().toString()}"
def file = project.layout.buildDirectory.file('resources/test/jacocoAgentJVMArgs.properties').get().asFile
file.write(jvmArgs)
}
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed'
}
systemProperty 'com.athaydes.spockframework.report.projectName', "${project.group}.${project.name}"
systemProperty 'com.athaydes.spockframework.report.projectVersion', "${project.version}"
finalizedBy project.tasks.jacocoTestReport
}
check {
dependsOn project.tasks.jacocoTestCoverageVerification
// dependsOn project.tasks.dependencyCheckAnalyze
}
configurations.configureEach {
exclude group: 'org.apache.logging.log4j', module: 'log4j-core'
}
dependencies {
implementation(
gradleApi(),
)
testImplementation(
gradleTestKit(),
localGroovy(),
// [group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.15']
)
testImplementation(
[group: 'org.spockframework', name: 'spock-core', version: property('spockVersion')],
) {
exclude group: 'org.codehaus.groovy'
}
testRuntimeOnly(
[group: 'com.athaydes', name: 'spock-reports', version: property('spockReportsVersion')]
) {
transitive = false
}
testRuntimeOnly(
[group: 'org.slf4j', name: 'slf4j-api', version: property('slf4jApiVersion')],
[group: 'org.slf4j', name: 'slf4j-simple', version: property('slf4jApiVersion')]
)
}