-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
280 lines (249 loc) · 7.92 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
/*
* @copyright defined in LICENSE.txt
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
google()
mavenCentral()
}
dependencies {
classpath 'me.champeau.gradle:jmh-gradle-plugin:0.4.7'
classpath "gradle.plugin.io.morethan.jmhreport:gradle-jmh-report:0.8.0"
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.14.0"
}
}
group 'io.aergo'
repositories {
mavenLocal()
maven {
url "http://dist.wso2.org/maven2"
}
mavenCentral()
jcenter()
}
allprojects {
group 'io.aergo'
version '1.0-RC1'
}
def javaProjects = [
project('core'),
project('bootstrap'),
project('assembly')]
def jmhProjects = [
]
configure(javaProjects) {
// do Java specific configurations
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'com.github.hierynomus.license-report'
apply plugin: 'idea'
apply plugin: 'eclipse'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
eclipseJdt.doLast( {
ant.propertyfile(file: ".settings/org.eclipse.core.resources.prefs") {
ant.entry(key: "eclipse.preferences.version", value: "1")
ant.entry(key: "encoding/<project>", value: "utf8")
}
} )
idea {
module {
outputDir file('build/classes/java/main')
testOutputDir file('build/classes/java/test')
}
}
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
repositories {
mavenLocal()
maven {
url "http://dist.wso2.org/maven2"
}
mavenCentral()
jcenter()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.2'
implementation 'org.slf4j:slf4j-api:1.7.25'
runtime 'ch.qos.logback:logback-classic:1.2.3'
testImplementation 'org.projectlombok:lombok:1.18.2'
testImplementation 'junit:junit:4.12'
testImplementation('org.powermock:powermock-api-mockito2:2.0.0-beta.5') {
exclude group: 'org.mockito', module: 'mockito-core'
}
testImplementation 'org.mockito:mockito-core:2.23.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.0-beta.5'
}
project.ext.jacocoOfflineSourceSets = [ 'main' ]
task instrument(dependsOn: [classes, project.configurations.jacocoAnt]) {
inputs.files classes.outputs.files
File outputDir = new File(project.buildDir, 'instrumentedClasses')
outputs.dir outputDir
doFirst {
project.delete(outputDir)
ant.taskdef(
resource: 'org/jacoco/ant/antlib.xml',
classpath: project.configurations.jacocoAnt.asPath,
uri: 'jacoco'
)
def instrumented = false
jacocoOfflineSourceSets.each { sourceSetName ->
if (file(sourceSets[sourceSetName].output.classesDir).exists()) {
def instrumentedClassedDir = "${outputDir}/${sourceSetName}"
ant.'jacoco:instrument'(destdir: instrumentedClassedDir) {
fileset(dir: sourceSets[sourceSetName].output.classesDir, includes: '**/*.class')
}
//Replace the classes dir in the test classpath with the instrumented one
sourceSets.test.runtimeClasspath -= files(sourceSets[sourceSetName].output.classesDir)
sourceSets.test.runtimeClasspath += files(instrumentedClassedDir)
instrumented = true
}
}
if (instrumented) {
//Disable class verification based on https://github.com/jayway/powermock/issues/375
test.jvmArgs += '-noverify'
}
}
}
test.dependsOn instrument
test {
if(JavaVersion.current().isJava9Compatible()) {
jvmArgs('--add-opens', 'java.base/java.lang=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.lang.invoke=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.io=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.nio=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.nio.file=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.base/java.text=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/sun.nio.fs=ALL-UNNAMED')
jvmArgs('--add-opens', 'java.rmi/sun.rmi.transport=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'
forkEvery = 1
}
checkstyle {
project.ext.checkstyleVersion = '8.11'
project.ext.sevntuChecksVersion = '1.26.0'
sourceSets = [project.sourceSets.main]
ignoreFailures = true
configFile = file("${rootProject.projectDir}/styles.xml")
reportsDir = file("${buildDir}/checkstyle-reports")
configurations {
checkstyle
}
checkstyleMain {
reportsDir = checkstyle.reportsDir
}
dependencies{
assert project.hasProperty("checkstyleVersion")
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
checkstyle "com.github.sevntu-checkstyle:sevntu-checks:${sevntuChecksVersion}"
}
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
publishing {
publications {
maven(MavenPublication) {
artifactId = 'ship-' + project.name
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
jacoco {
toolVersion = "0.8.2"
}
jacocoTestReport {
group = "Reporting"
additionalSourceDirs = files(sourceSets.main.allSource.srcDirs)
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = files(sourceSets.main.output.classesDir)
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
}
}
task alljavadoc(type: Javadoc) {
source javaProjects.collect { it.sourceSets.main.allJava }
classpath = files(javaProjects.collect { it.sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
options.addBooleanOption('html5', true)
}
apply plugin: 'java'
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.2"
}
task alljacoco(type: JacocoReport) {
dependsOn = javaProjects.test
sourceDirectories = files(javaProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(javaProjects.sourceSets.main.output.classesDir)
def executionDataPath = []
executionData = files((javaProjects.findAll { p ->
def coverageFileLocation = "$p.buildDir/jacoco/test.exec"
new File(coverageFileLocation).exists()
}).jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
csv.enabled = false
}
}
configure(jmhProjects) {
apply plugin: "me.champeau.gradle.jmh"
apply plugin: "io.morethan.jmhreport"
eclipse {
classpath {
plusConfigurations.add(configurations.jmhCompile)
defaultOutputDir = file('build/classes-jmh-ide')
}
}
sourceSets {
jmh {
compileClasspath += sourceSets.main.output + sourceSets.test.output + sourceSets.main.compileClasspath
runtimeClasspath += configurations.jmh + sourceSets.main.runtimeClasspath + sourceSets.test.runtimeClasspath
}
}
dependencies {
jmhCompile project
jmhCompile 'org.openjdk.jmh:jmh-core:1.21'
jmhCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.21'
jmhRuntime 'org.slf4j:jul-to-slf4j:1.7.25'
}
jmh {
duplicateClassesStrategy = 'warn'
resultFormat = 'JSON'
benchmarkMode = ['thrpt']
timeUnit = 's'
include += '.*Benchmark'
threads = 8
fork = 2
}
jmhReport {
jmhResultPath = project.file('build/reports/jmh/results.json')
jmhReportOutput = project.file('build/reports/jmh')
}
}