-
Notifications
You must be signed in to change notification settings - Fork 157
/
build.gradle
284 lines (224 loc) · 8.18 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
// tag::versions[]
buildscript {
dependencies {
apply from: "versions.gradle"
def depMgmtVersion = versions['dependency.management.plugin.version']
classpath "io.spring.gradle:dependency-management-plugin:${depMgmtVersion}"
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.9.2'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16'
classpath 'com.moowork.gradle:gradle-node-plugin:1.1.1'
classpath 'org.ajoberstar.git-publish:gradle-git-publish:3.0.1'
classpath 'org.ajoberstar.grgit:grgit-gradle:4.1.1'
// classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5-rc1'
classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.1"
classpath "com.github.rmee:jdk-bootstrap:${RMEE_GRADLE_VERSION}"
classpath 'com.bmuschko:gradle-docker-plugin:6.7.0'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.15.1'
}
}
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
wrapper {
gradleVersion = '6.9.2'
}
apply plugin: 'jdk-bootstrap'
jdk {
useAdoptOpenJdk8(JDK_VERSION)
}
// note that a production build creates javadoc, sources jars and signatures undesired during development
// for performance reasons
def isProductionBuild = project.hasProperty('mavenCentralUsername')
ext {
timestampedVersion = isProductionBuild
}
apply plugin: 'org.ajoberstar.grgit'
if (ext.timestampedVersion) {
def gitCommitTimestamp = grgit.head().date.format("yyyyMMddHHmmss", TimeZone.getTimeZone('GMT'))
version = BUILD_VERSION_PREFIX + "." + gitCommitTimestamp
} else {
version = '10.0.0-SNAPSHOT'
}
group = GROUP_ID
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
gradle.beforeProject { Project project ->
project.with {
apply plugin: "eclipse"
apply plugin: 'maven-publish'
def docs = project.name == 'crnk-documentation'
def ui = project.name == 'crnk-ui'
def testProject = project.name == 'crnk-test'
def legacyBraveProject = project.name == 'crnk-brave'
def bom = project.name == 'crnk-bom'
def examples = project.name.contains('example')
def genGradleProject = project.name.contains('crnk-gen-gradle')
if (!docs) {
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
if (!bom) {
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
testCompile group: 'org.assertj', name: 'assertj-core', version: '2.2.0'
// https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.2'
// https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.0-b180830.0359'
}
test {
useJUnitPlatform()
maxParallelForks = 1
testLogging {
exceptionFormat = 'full'
}
}
configurations.all {
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "log4j", module: "log4j"
}
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom 'io.projectreactor:reactor-bom:Bismuth-RELEASE'
mavenBom 'org.glassfish.jersey:jersey-bom:2.26'
}
dependencies {
dependency 'com.fasterxml.jackson.core:jackson-databind:2.9.10'
dependency 'com.fasterxml.jackson.core:jackson-annotations:2.9.10'
dependency 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.10'
dependency 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.9.10'
dependency 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.9.10'
dependency 'com.fasterxml.jackson.core:jackson-core:2.9.10'
dependency 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.10'
dependency 'org.reflections:reflections:0.9.11'
}
}
}
}
// TODO gradle publishing to maven central?
if (!docs && !examples && !testProject && !legacyBraveProject) {
apply plugin: "jacoco"
jacoco {
toolVersion = "0.8.5"
}
rootProject.tasks.jacocoMerge.executionData tasks.withType(Test)
rootProject.tasks.jacocoRootReport.additionalSourceDirs files(sourceSets.main.allSource.srcDirs)
def sourceDirs = rootProject.tasks.jacocoRootReport.sourceDirectories
def classDirs = rootProject.tasks.jacocoRootReport.classDirectories
def mainOutput = files(files(sourceSets.main.output).collect {
fileTree(dir: it, exclude: '**/legacy/**')
})
rootProject.tasks.jacocoRootReport.sourceDirectories.from files(sourceSets.main.allSource.srcDirs)
rootProject.tasks.jacocoRootReport.classDirectories.from mainOutput
rootProject.coveralls.sourceDirs.addAll(sourceSets.main.allSource.srcDirs.flatten())
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
}
apply plugin: 'maven-publish'
if (!docs && !examples) {
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: 'javadoc') {
from javadoc.destinationDir
classifier = 'javadoc'
}
plugins.withId("com.vanniktech.maven.publish.base") {
group = GROUP_ID
mavenPublishing {
publishToMavenCentral("DEFAULT")
// Will only apply to non snapshot builds.
// Uses credentials as described above, supports both regular and in memory signing.
signAllPublications()
pom {
name = "Crnk"
description = "A description of what my library does."
inceptionYear = "2020"
url = "https ://github.com/crnk-project/crnk-framework/"
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 = "crnk"
name = "crnk"
url = "https://github.com/crnk-project/"
}
}
scm {
url = "https://github.com/crnk-project/crnk-framework"
connection = "scm:git:git://github.com/crnk-project/crnk-framework.git"
developerConnection = "scm:git:ssh://[email protected]/crnk-project/crnk-framework.git"
}
}
}
}
apply plugin: "com.vanniktech.maven.publish.base"
mavenPublishing {
// available options:
// - JavaLibrary
// - GradlePlugin
// - AndroidLibrary
// - KotlinJvm
// - KotlinJs
// - KotlinMultiplatform
// the first parameter configures the javadoc jar, available options:
// - None
// - Empty
// - Javadoc
// - Dokka("dokkaHtml") - the parameter is the name of the Dokka task
// second one is for whether to publish sources, optional, defaults to true (not supported for KotlinMultiplatform(
// AndroidLibrary has a third parameter for which variant to publish, defaults to "release"
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
}
def releaseBuild = project.hasProperty('stable')
}
}
}
// coveralls setup
apply plugin: "jacoco"
apply plugin: "com.github.kt3k.coveralls"
def publishedProjects = subprojects.findAll {
it.name != 'crnk-documentation' && it.name != 'crnk-ui' && it.name != 'crnk-test' && !it.name.contains('example')
}
task jacocoMerge(type: JacocoMerge) {
destinationFile = new File(project.buildDir, 'jacoco/test.exec')
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
for (publishedProject in publishedProjects) {
dependsOn publishedProject.path + ":check"
}
}
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn tasks.jacocoMerge
executionData tasks.jacocoMerge.destinationFile
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
}
coveralls {
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoRootReport
}