-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
355 lines (298 loc) · 10.1 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*
* Copyright 2018 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:3.0.1'
}
}
plugins {
id "org.sonarqube" version "2.7"
id 'com.github.kt3k.coveralls' version '2.8.4'
id 'ch.netzwerg.release' version '1.2.5'
id 'org.ajoberstar.git-publish' version '3.0.0-rc.1'
id "de.marcphilipp.nexus-publish" version "0.4.0"
id 'io.codearte.nexus-staging' version '0.21.1'
id "com.diffplug.spotless" version "5.4.0"
id 'jacoco'
id 'signing'
id 'java-library'
id 'java'
}
apply plugin: 'nebula-aggregate-javadocs'
ext {
vertxVersion = "3.5.0"
rxjavaVersion = "2.1.7"
junitVersion = "5.9.0"
catbufferVersion = "0.1.5"
restApiVersion = "1.0.3"
jackson_version = "2.9.9"
jackson_databind_version = "2.9.9"
}
def encoding = "UTF-8"
repositories {
mavenLocal()
mavenCentral()
}
def getPropertyValue(key, defaultValue = null) {
def value = project.hasProperty(key) ? project[key] : System.getenv(key)
return value == null || value.trim() == '' ? defaultValue : value
}
def ossrhUsername = getPropertyValue('ossrhUsername');
def ossrhPassword = getPropertyValue('ossrhPassword');
def sonarProjectKey = getPropertyValue('sonarProjectKey');
def sonarLogin = getPropertyValue('sonarLogin');
def sonarOrganization = getPropertyValue('sonarOrganization');
def sonarHostUrl = getPropertyValue('sonarHostUrl');
def sonarBranchName = getPropertyValue('sonarBranchName');
def signingSecretKeyRingFile = getPropertyValue('signingSecretKeyRingFile')
def signingKeyId = getPropertyValue('signingKeyId')
def signingPassword = getPropertyValue('signingPassword')
def githubToken = getPropertyValue('GITHUB_TOKEN')
def repoPath = getPropertyValue('TRAVIS_REPO_SLUG', "nemtech/symbol-sdk-java")
def artifactVersion = getPropertyValue('VERSION', rootProject.file('version.txt').text.trim() + '-SNAPSHOT')
def isReleaseVersion = !artifactVersion.contains("SNAPSHOT")
System.out.println("Current Version: " + artifactVersion)
allprojects {
ext."signing.keyId" = signingKeyId
ext."signing.secretKeyRingFile" = signingSecretKeyRingFile
ext."signing.password" = signingPassword
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'jacoco'
apply plugin: 'signing'
apply plugin: 'org.sonarqube'
apply plugin: 'de.marcphilipp.nexus-publish'
apply plugin: 'project-report'
apply plugin: 'com.diffplug.spotless'
group 'io.nem'
spotless {
java {
importOrder()
removeUnusedImports()
googleJavaFormat('1.7')
licenseHeaderFile '../LICENSE_HEADER'
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
version = artifactVersion
compileJava.options.encoding = encoding
compileTestJava.options.encoding = encoding
javadoc.options.encoding = encoding
signing {
required { signingKeyId }
sign publishing.publications
}
task checkForSnapshotDependencies {
onlyIf { isReleaseVersion }
doLast {
allprojects { project ->
project.configurations.runtime.each {
if (it.toString().contains("-SNAPSHOT"))
throw new Exception("Release build contains snapshot dependencies: " + it)
}
}
}
}
jar.dependsOn checkForSnapshotDependencies
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
javadoc {
// options.addBooleanOption('html5', true)
failOnError = true
source = sourceSets.main.allJava
classpath = configurations.compile
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
artifacts {
archives javadocJar, sourcesJar
}
test {
exclude '**/**IntegrationTest.class'
useJUnitPlatform {
includeEngines 'junit-jupiter'
}
testLogging {
events "skipped", "failed"
}
}
jacocoTestReport {
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
}
dependencies {
// Tests
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.mockito:mockito-all:1.9.5'
testImplementation(platform("org.junit:junit-bom:$junitVersion"))
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
}
if (project.name != "integration-tests") {
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
packaging = 'jar'
url = "https://github.com/${repoPath}"
name = "${project.name}"
description = "${project.name} lib for Sybol SDK Java"
scm {
connection = "scm:git:https://github.com/${repoPath}.git"
developerConnection = "scm:svn:https://github.com/${repoPath}"
url = "https://github.com/${repoPath}"
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'fullcircle23'
name = 'Ravi Shanker'
}
developer {
id = 'rg911'
name = 'Steven Liu'
}
developer {
id = 'fboucquez'
name = 'Fernando Boucquez'
}
}
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
username = ossrhUsername
password = ossrhPassword
}
}
connectTimeout = Duration.ofSeconds(360)
clientTimeout = Duration.ofSeconds(360)
}
}
def publishedProjects = subprojects
task jacocoMerge(type: JacocoMerge) {
publishedProjects.each { subproject ->
executionData subproject.tasks.withType(Test)
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn publishedProjects.test, jacocoMerge
additionalSourceDirs.from = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories.from = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories.from = files(publishedProjects.sourceSets.main.output)
executionData jacocoMerge.destinationFile
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
afterEvaluate {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it)
})
}
}
coveralls {
sourceDirs = publishedProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoRootReport
}
gitPublish {
if (githubToken) {
repoUri = "https://github.com/${repoPath}.git".toString()
} else {
repoUri = "git@github.com:${repoPath}.git".toString()
}
branch = 'gh-pages'
preserve { include '**/*' }
commitMessage = "Publishing SDK Javadocs for version ${artifactVersion}".toString()
contents {
from(file("$buildDir/docs/javadoc")) {
into "javadoc/${artifactVersion}".toString()
}
}
}
gitPublishPush.dependsOn("aggregateJavadocs")
def gitBranch() {
def branch = ""
def proc = "git rev-parse --abbrev-ref HEAD".execute()
proc.in.eachLine { line -> branch = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
branch
}
release {
push = false
}
nexusStaging {
packageGroup = "io.nem"
stagingProfileId = "365f7aa90b3b13"
username = ossrhUsername
password = ossrhPassword
numberOfRetries = 40
delayBetweenRetriesInMillis = 10000
}
release.dependsOn subprojects.install
sonarqube {
properties {
// property "sonar.branch.name", sonarBranchName == null ? gitBranch() : sonarBranchName
property "sonar.projectKey", sonarProjectKey
property "sonar.projectName", sonarProjectKey
property "sonar.organization", sonarOrganization
property "sonar.login", sonarLogin
property "sonar.host.url", sonarHostUrl
}
}