-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
298 lines (245 loc) · 9.69 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
buildscript {
// include versions script
apply from: rootProject.file('gradle/lib-versions.gradle')
repositories {
mavenCentral()
}
dependencies {
classpath("io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE")
}
}
// Plugin for support environment's with gradle.properties (gradle-local.properties is default local environment)
plugins {
id 'net.saliman.properties' version "1.5.2"
id 'org.ajoberstar.grgit' version "5.0.0"
id "com.github.spotbugs" version '5.0.9'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'maven-publish'
}
apply from: rootProject.file('gradle/git.gradle')
apply plugin: 'base'
// project parameters
project.group = property('app.group')
project.description = property('app.description')
// project version
apply from: rootProject.file('gradle/version.gradle')
spotbugs {
toolVersion = "${versions.spotbugToolVersion}"
ignoreFailures = true
}
wrapper {
gradleVersion = "${versions.gradle}"
}
allprojects {
group = property('app.group')
}
apply from: rootProject.file('gradle/nexus-staging.gradle')
subprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'java-library'
apply from: rootProject.file('gradle/jacoco.gradle')
version = parent.version
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
[compileJava, compileTestJava]*.options.collect {
options -> options.encoding = "UTF-8"
options.compilerArgs << '-parameters'
}
repositories {
mavenCentral()
}
dependencies {
compileOnly "org.projectlombok:lombok:${versions.lombok}"
testCompileOnly "org.projectlombok:lombok:${versions.lombok}"
annotationProcessor "org.projectlombok:lombok:${versions.lombok}"
testAnnotationProcessor "org.projectlombok:lombok:${versions.lombok}"
}
test {
systemProperty("java.awt.headless", "true")
systemProperty("testGroups", project.properties.get("testGroups"))
include '**/*UnitTest*'
include '**/*IntTest*'
// uncomment if the tests reports are not generated
// see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
// ignoreFailures true
reports.html.enabled = true
testLogging {
exceptionFormat = 'full'
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/tests")
reportOn test
}
test.finalizedBy(testReport)
javadoc {
description = "Generates project-level javadoc for use in -javadoc jar"
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
options.author = true
options.header = project.name
options.use = true
//options.links(project.ext.javadocLinks)
options.addStringOption('Xdoclint:none', '-quiet')
// Suppress warnings due to cross-module @see and @link references.
// Note that global 'api' task does display all warnings.
//logging.captureStandardError LogLevel.INFO
//logging.captureStandardOutput LogLevel.INFO // suppress "## warnings" message
}
task javadocJar(type: Jar) {
getArchiveClassifier().set('javadoc')
from javadoc
}
task sourcesJar(type: Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
getArchiveClassifier().set('sources')
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
task allDeps(type: DependencyReportTask) {}
checkstyle {
toolVersion = versions.checkstyle
ignoreFailures = true
configFile = rootProject.file('qa/checkstyle.xml')
sourceSets = [sourceSets.main]
}
pmd {
rulesMinimumPriority = 3
toolVersion = versions.pmd
ignoreFailures = true
ruleSetFiles = rootProject.files('qa/pmd.xml')
sourceSets = [sourceSets.main]
}
// use `afterEvaluate` for init some pom values or jar manifest from sub-projects (for example: description)
afterEvaluate {
publishing {
def projectDescription = ((project.description != null) ? project.description : project.name)
jar {
manifest {
attributes(
'Implementation-Vendor': project.property('app.vendor'),
'Specification-Title': projectDescription,
'SCM-Branch': rootProject.ext.gitBranch,
'SCM-Revision': rootProject.ext.gitRevision,
'SCM-Revision-Abbreviated': rootProject.ext.gitAbbreviatedRevision
)
}
}
repositories {
if (!project.hasProperty('ossrhUsername') || !project.hasProperty('ossrhPassword')) {
mavenLocal()
logger.lifecycle("No OSS RH user credentail defined - you can't deploy artifacts")
} else {
if (isRelease(project)) {
// id: 'sonatype-nexus-staging',
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username ossrhUsername
password ossrhPassword
}
}
} else {
// id: 'sonatype-nexus-snapshots'
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
packaging = 'jar'
name = project.name
description = projectDescription
url = 'https://xm.icthh.com'
scm {
url = 'https://github.com/xm-online/xm-commons'
connection = 'scm:git:git://github.com/xm-online/xm-commons.git'
developerConnection = 'scm:git:git://github.com/xm-online/xm-commons.git'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'vkyrychenko'
name = 'Vitalii Kyrychenko'
email = 'vitalii.kyrychenko@jevera.software'
}
developer {
id = 'amedvedchuk'
name = 'Anatoliy Medvedchuk'
}
developer {
id = 'ishkurko'
name = 'Igor Shkurko'
email = 'ishkurko@icthh.com'
}
developer {
id = 'ssenko'
name = 'Serhii Senko'
}
}
}
// remove test dependencies from pom file
pom.withXml {
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
it.scope.text() == 'test'
}.each() {
it.parent().remove(it)
}
}
}
}
}
signing {
// We only want to require signing if we are building a release version and we are going to publish it.
// Because we are inspecting the task graph to determine if we are going to be publishing,
// we must set the signing.required property to a closure to defer the evaluation
required {
isRelease(project) && gradle.taskGraph.hasTask("publish")
}
//sign configurations.archives
sign publishing.publications.mavenJava
}
}
}
boolean isRelease(Project project) {
def semVer = SemVersion.valueOf(String.valueOf(project.version))
return semVer.isRelease()
}
clean.doFirst {
delete rootProject.buildDir
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}