forked from crnk-project/crnk-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
315 lines (245 loc) · 10.7 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
// 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:gradle-git-publish:0.4.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.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.bmuschko:gradle-docker-plugin:3.2.8'
}
}
wrapper {
gradleVersion = '5.2.1'
}
// note that a production build creates javadoc, sources jars and signatures undesired during development
// for performance reasons
def isProductionBuild = System.env.NEXUS_DEPLOY_USER != null
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'
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')
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'
}
}
}
}
if (!docs && !examples && !testProject && !legacyBraveProject) {
apply plugin: "jacoco"
jacoco {
toolVersion = "0.7.6.201602180812"
}
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/**')
})
if (sourceDirs == null) {
rootProject.tasks.jacocoRootReport.sourceDirectories = files(sourceSets.main.allSource.srcDirs)
rootProject.tasks.jacocoRootReport.classDirectories = mainOutput
} else {
rootProject.tasks.jacocoRootReport.sourceDirectories = sourceDirs.plus(files(sourceSets.main.allSource.srcDirs))
rootProject.tasks.jacocoRootReport.classDirectories = classDirs.plus(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'
}
apply plugin: 'com.jfrog.bintray'
// Create the pom configuration:
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
id 'crnk.io'
name 'crnk.io'
email '[email protected]'
}
}
scm {
url "https://github.com/crnk-project/crnk-framework"
}
}
if (!bom) {
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
groupId GROUP_ID
artifactId project.name
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', 'JSON API with Crnk')
root.appendNode('name', 'Crnk')
root.appendNode('url', 'https://www.crnk.io')
root.children().last() + pomConfig
}
}
}
}
}
def releaseBuild = project.hasProperty('stable')
bintray {
user = System.env.BINTRAY_USER
key = System.env.BINTRAY_TOKEN
publications = ['mavenJava']
pkg {
repo = releaseBuild ? 'maven' : 'mavenLatest'
name = project.name
userOrg = 'crnk-project'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/crnk-project/crnk-framework.git'
websiteUrl = 'http://www.crnk.io'
desc = 'JSON API with Crnk'
labels = ['JSONAPI', 'rest']
githubRepo = 'crnk-project/crnk-framework'
githubReleaseNotesFile = 'README.md'
publish = !releaseBuild
version {
name = project.version
desc = 'JSON API with Crnk'
released = new Date()
vcsTag = "v$project.version"
mavenCentralSync {
sync = false //[Default: true] Determines whether to sync the version to Maven Central.
user = System.env.NEXUS_DEPLOY_USER
password = System.env.NEXUS_DEPLOY_PASS
close = '1'
}
}
}
}
tasks.bintrayUpload.dependsOn assemble, sourcesJar, javadocJar, publishToMavenLocal
publish.dependsOn tasks.bintrayUpload
}
}
}
// 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
}