-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle
260 lines (236 loc) · 8.58 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id 'com.github.kt3k.coveralls' version '2.12.0'
id 'com.marklogic.ml-gradle' version '4.5.2'
id 'org.sonarqube' version '3.3'
id 'eclipse'
id 'idea'
id 'jacoco'
id 'java-library'
id 'maven-publish'
id 'signing'
}
ext {
// 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%%', '9000')
createTriggersDatabase = false
}
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
}
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 {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
performanceTestImplementation.extendsFrom testImplemenation
performanceTestRuntimeOnly.extendsFrom testRuntimeOnly
}
dependencies {
api group: 'com.marklogic', name: 'marklogic-xcc', version: '11.0.2'
api group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.19'
api group: 'org.ogce', name: 'xpp3', version: '1.1.6'
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.3'
testImplementation 'junit:junit:4.13.2'
}
jar {
manifest {
attributes 'Build-date' : new Date()
attributes 'Main-Class' : 'com.marklogic.ps.xqsync.XQSync'
attributes 'Class-Path' : configurations.runtimeClasspath.collect { 'lib/' + it.getName() }.join(' ')
//XQSync class reads the version for usage messages
attributes 'Implementation-Version' : project.version
}
}
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'
}
test {
testLogging {
events TestLogEvent.STARTED,TestLogEvent.PASSED
}
//we will run Integration and Performance tests in separate tasks
exclude '**/*IT*'
exclude '**/*PT*'
}
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
task integrationTest(type: Test, dependsOn: test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
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 {
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) {
testClassesDirs = sourceSets.performanceTest.output.classesDirs
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 {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
//groupId = project.group
//artifactId = project.name
version = project.version
name project.name
url project.websiteUrl
scm {
url project.vcsUrl
}
issueManagement {
system 'GitHub Issues'
url project.issueTrackerUrl
}
inceptionYear '2010'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
description 'XQSync is a Java command-line tool. The entry point is the main method in the com.marklogic.ps.xqsync.XQSync class. This class takes zero or more property files as its arguments. Any specified system properties will override file-based properties, and properties found in later files may override properties specified in earlier files on the command line.'
developers {
developer {
name 'Mads Hansen'
email '[email protected]'
organization 'MarkLogic'
}
}
}
}
}
}
repositories {
maven {
url ossURL
credentials {
username ossUsername
password ossPassword
}
}
}
}
signing {
sign publishing.publications.mavenJava
}