-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.bak
336 lines (274 loc) · 8.99 KB
/
build.gradle.bak
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
/*
* @copyright defined in LICENSE.txt
*/
buildscript {
// repositories {
// maven {
// url "https://plugins.gradle.org/m2/"
// }
// google()
// mavenCentral()
// }
// dependencies {
// classpath "me.champeau.gradle:jmh-gradle-plugin:${jmhPluginVersion}"
}
plugins {
id "me.champeau.jmh" version "0.6.6" // micro bmt
}
allprojects {
apply plugin: 'java-library'
apply plugin: 'idea'
repositories {
mavenLocal()
mavenCentral()
}
/* java-library */
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
sourceCompatibility = sourceJavaVersion
targetCompatibility = targetJavaVersion
task sourceJar(type: Jar) {
from sourceSets.main.allJava
getArchiveClassifier().set('sources')
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
task javadocJar(type: Jar) {
from javadoc
getArchiveClassifier().set('javadoc')
}
artifacts {
archives sourceJar
archives javadocJar
}
test {
if (JavaVersion.current().isJava9Compatible()) {
jvmArgs('--add-opens', 'java.base/java.lang=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.lang.invoke=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.math=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.net=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.nio=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.util=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.util.stream=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.io=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.xml/jdk.xml.internal=ALL-UNNAMED')
}
maxParallelForks = Math.max(1, Runtime.runtime.availableProcessors())
exclude '**/*Tests.class'
exclude '**/*IT.class'
}
task integrationTest(type: Test) {
if (JavaVersion.current().isJava10Compatible()) {
jvmArgs('--add-opens', 'java.base/java.lang=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.lang.invoke=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.math=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.net=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.nio=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.util=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.util.stream=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.io=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.xml/jdk.xml.internal=ALL-UNNAMED')
}
// note that every *IT class must have own wallet
maxParallelForks = Math.max(1, Runtime.runtime.availableProcessors())
include '**/*IT.class'
}
/* idea */
idea {
module {
outputDir file('build/classes/java/main')
testOutputDir file('build/classes/java/test')
}
}
task copyDependencies(type: Copy) {
into "$buildDir/dependencies"
// from configurations.runtime
from configurations.runtimeClasspath
}
}
def javaLibraryProjects = [
project('core:annotation'),
project('core:util'),
project('core:common'),
project('core:protobuf'),
project('core:transport'),
project('client:wallet'),
project('client:smart-contract')
]
configure(javaLibraryProjects) {
apply plugin: 'jacoco' // coverage
apply plugin: 'checkstyle' // lint
def projectBaseName = 'heraj-' + project.name
dependencies {
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
runtimeOnly "ch.qos.logback:logback-classic:${logbackVersion}"
testImplementation "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testImplementation "junit:junit:${junitVersion}"
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
testImplementation("org.powermock:powermock-api-mockito2:${powerMockVersion}") {
exclude group: 'org.mockito', module: 'mockito-core'
}
testImplementation "org.powermock:powermock-module-junit4:${powerMockVersion}"
}
/* checkstyle */
checkstyle {
toolVersion checkstyleVersion
sourceSets = [project.sourceSets.main]
configFile = file("${project.rootProject.projectDir}/styles.xml")
}
task lint {
dependsOn check
}
/* jacoco */
jacoco {
toolVersion jacocoVersion
}
// need test task before executing
jacocoTestReport {
group = "Reporting"
getAdditionalSourceDirs().setFrom(sourceSets.main.allSource.srcDirs)
getSourceDirectories().setFrom(sourceSets.main.allSource.srcDirs)
getClassDirectories().setFrom(sourceSets.main.output.classesDirs)
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
}
task coverage {
dependsOn jacocoTestReport
}
jar {
archivesBaseName = projectBaseName
}
/* jmh */
jmh {
fork = 2
benchmarkMode = ['thrpt']
resultFormat = 'JSON'
timeUnit = 's'
threads = 2 * Runtime.runtime.availableProcessors()
// jmhVersion = '1.21'
duplicateClassesStrategy = org.gradle.api.file.DuplicatesStrategy.WARN
}
}
// root project
project(":") {
apply plugin: 'jacoco' // coverage
apply plugin: 'maven-publish' // maven
apply plugin: 'signing' //
task allcoverage(type: JacocoReport) {
def targetProjects = javaLibraryProjects.findAll {
it.name != 'annotation' && it.name != 'protobuf'
}
dependsOn = targetProjects.coverage
getSourceDirectories().setFrom(targetProjects.sourceSets.main.allSource.srcDirs)
getClassDirectories().setFrom(targetProjects.sourceSets.main.output.classesDirs)
getExecutionData().setFrom(targetProjects.jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
csv.enabled = false
}
afterEvaluate {
getClassDirectories().setFrom(classDirectories.files.collect {
fileTree(dir: it, exclude: ['types/**'])
})
}
}
task alljavadoc(type: Javadoc) {
def targetProjects = javaLibraryProjects.findAll {
it.name != 'protobuf'
}
source targetProjects.collect { it.sourceSets.main.allJava }
classpath = files(targetProjects.collect { it.sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xwerror', '-quiet')
}
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
/* maven-publish */
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
// artifactId = projectBaseName
version = project.version
from components.java
artifact sourceJar
artifact javadocJar
}
mavenJava(MavenPublication) {
pom {
name = 'heraj'
packaging = 'jar'
// optionally artifactId can be defined here
description = 'A java SDK for accessing blockchain Aergo.'
url = 'https://github.com/aergoio/heraj'
scm {
connection = 'scm:git:https://github.com/aergoio/heraj.git'
developerConnection = 'scm:git:https://github.com/aergoio/heraj.git'
url = 'https://github.com/aergoio/heraj'
}
licenses {
license {
name ='MIT'
url = 'https://github.com/aergoio/heraj/blob/develop/LICENSE.txt'
}
}
developers {
developer {
id = 'hayarobi'
name = 'Hayarobi Park'
email = '[email protected]'
}
developer {
id = 'acktsap'
name = 'Taeik Lim'
email = '[email protected]'
}
developer {
id = 'bylee'
name = 'bonyong lee'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = project.hasProperty('ossrhUsername') ? ossrhUsername : "Unknown user"
password = project.hasProperty('ossrhPassword') ? ossrhPassword : "Unknown password"
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
// tasks.withType(Sign) {
// onlyIf { isReleaseVersion }
// }
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
}