forked from marklogic-community/corb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
300 lines (273 loc) · 10.3 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id 'com.jfrog.bintray' version '1.8.4'
id 'com.github.johnrengelman.shadow' version '2.0.2'
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'com.marklogic.ml-gradle' version '3.12.0'
id 'io.github.ddimtirov.codacy' version '0.1.0'
id 'org.sonarqube' version '2.6.2'
id 'eclipse'
id 'idea'
id 'jacoco'
id 'java'
id 'maven-publish'
}
ext {
externalsortinginjavaVersion = '0.2.5'
// we don't need a REST server, only an XCC server
mlAppDeployer.getCommands().remove(mlAppDeployer.getCommand('DeployRestApiServersCommand'))
mlAppConfig {
name = project.name
customTokens.put('%%XDBC_PORT%%', '8223')
createTriggersDatabase = false
}
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
jcenter()
flatDir {
dirs 'src/test/resources/'
}
//required for codacyUpload task
maven { url "http://dl.bintray.com/typesafe/maven-releases" }
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/test/java')
}
resources.srcDir file('src/test/resources')
}
performanceTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/test/java')
}
resources.srcDir file('src/test/resources')
}
}
configurations {
shadow
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
performanceTestCompile.extendsFrom testCompile
performanceTestRuntime.extendsFrom testRuntime
}
dependencies {
compile 'com.marklogic:marklogic-xcc:9.0.9'
//we bundle the externalsortinginjava classes with the corb distro as a fat jar
compileOnly "com.google.code.externalsortinginjava:externalsortinginjava:$externalsortinginjavaVersion"
shadow "com.google.code.externalsortinginjava:externalsortinginjava:$externalsortinginjavaVersion"
testCompile "com.google.code.externalsortinginjava:externalsortinginjava:$externalsortinginjavaVersion"
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'org.jasypt:jasypt:1.9.2'
testCompile 'com.github.stefanbirkner:system-rules:1.17.1' //facilitates tests for methods that invoke System.exit
testCompile 'org.mockito:mockito-all:1.10.19'
}
test {
testLogging {
events TestLogEvent.STARTED,TestLogEvent.PASSED
}
//we will run Integration and Performance tests in separate tasks
exclude '**/*IT.class'
exclude '**/*PT.class'
}
//disabling, because we want to incorporate externalsortingjava in uber jar and use as the artifact
jar.enabled = false
shadowJar {
configurations = [project.configurations.compile, project.configurations.shadow]
dependencies {
include(dependency("com.google.code.externalsortinginjava:externalsortinginjava:$externalsortinginjavaVersion"))
}
//generate same name as the jar task would
archiveName = "${baseName}-${version}.${extension}"
manifest {
attributes 'Application-Version': project.version
attributes 'Build-date' : new Date()
attributes 'Main-Class' : 'com.marklogic.developer.corb.Manager'
attributes 'Name': 'com/marklogic/developer/corb/'
attributes 'Specification-Title' : 'corb'
attributes 'Specification-Version' : project.version
attributes 'Implementation-Title' : project.name
//Manager class reads the version for usage messages
attributes 'Implementation-Version' : project.version
}
}
build.dependsOn(shadowJar)
task sourcesJar(type: Jar, dependsOn: classes) {
description = "Create a JAR of source files; required by bintray for publishing"
classifier 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
task integrationTest(type: Test, dependsOn: test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
filter {
//include all integration tests
includeTestsMatching "*IT"
}
testLogging {
events TestLogEvent.STARTED,TestLogEvent.PASSED
}
//If you want to ensure that integration tests are run every time when you invoke
//this task, uncomment the following line.
//outputs.upToDateWhen { false }
jacoco {
//coverage report will include both unit and integration tests
append = true
destinationFile = file("$buildDir/jacoco/test.exec")
}
//generate the Jacoco report
finalizedBy { tasks.integrationTestReport }
}
task integrationTestReport(type: JacocoReport) {
sourceSets sourceSets.main
executionData integrationTest
}
task performanceTest(type: Test) {
testClassesDir = sourceSets.performanceTest.output.classesDir
classpath = sourceSets.performanceTest.runtimeClasspath
filter {
//include all performance tests
includeTestsMatching "*PT"
}
testLogging {
events TestLogEvent.STARTED,TestLogEvent.PASSED
}
//If you want to ensure that performance tests are run every time when you invoke
//this task, uncomment the following line.
outputs.upToDateWhen { false }
}
check.dependsOn jacocoTestReport
//Ensure that the check task fails the build if there are failing integration tests.
check.dependsOn integrationTest
//Ensure that our unit tests are run before our integration tests
integrationTest.mustRunAfter test
integrationTest.onlyIf { !project.hasProperty('skipIntegrationTest') }
//Ensure that the check task fails the build if there are failing performance tests.
//check.dependsOn performanceTest
//Ensure that our unit tests are run before our performance tests
performanceTest.mustRunAfter integrationTest
performanceTest.onlyIf { !project.hasProperty('skipPerformanceTest') }
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
showExceptions true
exceptionFormat TestExceptionFormat.SHORT
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug {
events TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR
exceptionFormat TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
tasks.coveralls {
dependsOn 'check'
}
publishing {
publications {
mainJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name "corb"
url project.websiteUrl
scm {
url project.vcsUrl
}
issueManagement {
system "GitHub Issues"
url project.issueTrackerUrl
}
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
description 'CoRB is a Java tool designed for bulk content-reprocessing of documents stored in MarkLogic.'
developers {
developer {
name "Bhagat Bandlamudi"
email "[email protected]"
organization "MarkLogic"
}
developer {
name "Mads Hansen"
email "[email protected]"
organization "MarkLogic"
}
}
}
}
}
}
}
/*
* In order to publish to bintray, you need an account. Once you have that account, set myBintrayUser and myBintrayKey
* to your username and key. You can do that in the project gradle.properties file, but it's better to do so in your
* ~/.gradle/gradle.properties file. Once you do that, you can run "gradle -i bintray" to publish it to bintray.
*/
if (project.hasProperty("myBintrayUser")) {
bintray {
user = myBintrayUser
key = myBintrayKey
publications = ['mainJava']
//dryRun = true
pkg {
repo = 'maven'
name = project.name
licenses = ['Apache-2.0']
userOrg = 'marklogic'
websiteUrl = project.websiteUrl
issueTrackerUrl = project.issueTrackerUrl
vcsUrl = project.vcsUrl
githubRepo = 'marklogic-community/corb2'
githubReleaseNotesFile = 'README.md'
version {
name = project.version
released = new Date()
}
}
}
}