forked from crate/crate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
321 lines (270 loc) · 9.87 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'de.thetaphi:forbiddenapis:2.0'
}
}
plugins {
id 'me.champeau.gradle.jmh' version '0.2.0'
}
def download(File downloadDir, String url, String name) {
downloadDir.mkdirs()
def dest = new File(downloadDir, name)
ant.get(
src: url,
verbose: true,
usetimestamp: true,
skipexisting: true,
dest: dest
)
return dest;
}
ext {
versions = [
// update this value when elasticsearch is updated
elasticsearch: "2.3.4"
]
}
repositories {
mavenCentral()
}
allprojects {
apply plugin: 'findbugs'
apply plugin: 'jacoco'
configurations.all {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
failOnVersionConflict()
// ES requires hamcrest-all which includes hamcrest-core
dependencySubstitution {
substitute module('org.hamcrest:hamcrest-core') with(
module('org.hamcrest:hamcrest-all:1.3'))
}
// forced versions of conflicting deps
force 'com.spatial4j:spatial4j:0.5'
force 'com.google.guava:guava:18.0'
force 'commons-codec:commons-codec:1.10'
force 'com.carrotsearch.randomizedtesting:junit4-ant:2.3.1'
force 'com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.3.1'
force 'junit:junit:4.11'
force 'org.slf4j:slf4j-api:1.6.2'
force 'com.fasterxml.jackson.core:jackson-core:2.6.2'
force 'joda-time:joda-time:2.8.2'
force 'org.hamcrest:hamcrest-all:1.3'
force 'org.antlr:antlr-runtime:3.5.2'
force 'commons-cli:commons-cli:1.3.1'
force 'org.apache.commons:commons-math3:3.4.1'
force 'org.apache.commons:commons-lang3:3.3.2'
force 'commons-logging:commons-logging:1.1.3'
force 'org.apache.httpcomponents:httpcore:4.3.3'
force 'org.apache.httpcomponents:httpclient:4.3.6'
force 'org.slf4j:slf4j-log4j12:1.7.10'
force 'log4j:log4j:1.2.17'
force 'io.netty:netty:3.10.5.Final'
// ensure to check following dependencies and their versions against those of HDFS plugin libs
// https://crate.io/docs/reference/en/latest/sql/snapshot_restore.html
force 'org.codehaus.jackson:jackson-core-asl:1.9.13'
force 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
force 'com.google.code.findbugs:jsr305:3.0.1'
force 'commons-lang:commons-lang:2.6'
}
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
options.encoding = 'UTF-8'
}
tasks.withType(Test) {
// force run, see: http://gradle.1045684.n5.nabble.com/how-does-gradle-decide-when-to-run-tests-td3314172.html
outputs.upToDateWhen { false }
// allow to set the number of test forks from the CLI
if (project.hasProperty('testForks')) {
maxParallelForks = project.testForks as int
}
if (project.hasProperty('disableAssertions')) {
enableAssertions = false
// LuceneTestCase defaults this value to 'true' if not set which results in an exception if '-ea' is skipped
systemProperty "tests.asserts", "false"
}
// tell ES to add required permissions for gradle
systemProperty "tests.gradle", "true"
}
jacoco {
toolVersion = "0.7.1.201405082137"
}
group = 'io.crate'
findbugs {
ignoreFailures = true
}
// if environment variable JAVA7_HOME is set, add it to bootClasspath
// for compiling for java 7 compatibility using javac from jdk8
tasks.withType(JavaCompile) {
doFirst {
if (sourceCompatibility == '1.7' && System.env.JAVA7_HOME != null) {
options.fork = true
options.bootClasspath = "$System.env.JAVA7_HOME/jre/lib/rt.jar"
}
}
}
tasks.withType(Javadoc) {
failOnError = false
}
tasks.withType(Test) {
doFirst {
// move lucene-test-framework to the beginning of the classpath
// for cli ./gradlew use
def cp = project.sourceSets.test.runtimeClasspath
def testFrameworkEntry = cp.find({ it.name.contains("lucene-test-framework") })
if (testFrameworkEntry != null) {
project.sourceSets.test.runtimeClasspath = files(testFrameworkEntry) + cp.filter({
!it.name.contains("lucene-test-framework")
})
}
}
}
}
// intellij configuration
allprojects {
apply plugin: 'idea'
project.ext {
isIdea = (System.getProperty("idea.active") != null
|| gradle.startParameter.taskNames.contains('idea')
|| gradle.startParameter.taskNames.contains('cleanIdea')
|| gradle.startParameter.taskNames.contains('cleanIdeaBuild'))
}
if (isIdea) {
project.buildDir = file('build-idea')
}
idea {
module {
inheritOutputDirs = false
outputDir = file('build-idea/classes/main')
testOutputDir = file('build-idea/classes/test')
excludeDirs += file('build')
}
}
task cleanIdeaBuild << {
tasks.clean.execute()
}
}
final testOutputs = [:].withDefault { [] }
project.gradle.addListener(new TestOutputListener() {
@Override
void onOutput(TestDescriptor test, TestOutputEvent outputEvent) {
testOutputs[test] << outputEvent.getMessage()
}
})
project.gradle.addListener(new TestListener() {
@Override
void beforeSuite(TestDescriptor suite) {
logger.lifecycle('Running: ' + suite)
}
@Override
void afterSuite(TestDescriptor suite, TestResult result) {
}
@Override
void beforeTest(TestDescriptor test) {
}
@Override
void afterTest(TestDescriptor test, TestResult result) {
if (result.getResultType() == TestResult.ResultType.FAILURE) {
logger.error('## FAILURE: ' + test)
testOutputs[test].each { e ->
print e
}
}
testOutputs.remove(test)
}
})
def jacocoProjects() {
subprojects.findAll {
it.name != 'es' && it.name != 'testing'
}
}
task jacocoReport(type: JacocoReport) {
// tests must have been executed so that execution data for the sub projects is generated
// this task doesn't define a hard dependency on the tests to avoid running them twice in travis-ci
executionData fileTree(project.rootDir.absolutePath).include('**/build/jacoco/*.exec')
jacocoProjects().each {
evaluationDependsOn(it.name)
if (it.plugins.withType(JavaPlugin) && it.tasks.withType(Test)) {
sourceSets it.sourceSets.main
}
}
reports {
xml {
enabled true
destination "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
csv.enabled false
html {
enabled true
destination "${buildDir}/reports/jacoco/jacocoHtml"
}
}
}
subprojects {
idea {
module {
iml {
// ensure testing dependencies come before es dependencies
// when calling tests from intellij
withXml {
def node = it.asNode()
def testFramework = node.component.orderEntry.find {
it.@'type' == 'module-library' && it.library.CLASSES.root.find {
it.@'url'.contains('lucene-test-framework')
}
}
if (testFramework != null) {
println "moving test framework"
def parent = testFramework.parent()
def newNode = new Node(parent, testFramework.name(), testFramework.attributes(), testFramework.value())
parent.remove(testFramework)
parent.children().add(5, newNode)
}
}
}
}
}
}
def jvmTestFlags = ['-ea', "-Dproject_build_dir=$project.buildDir", '-Dproject_root=$PROJECT_DIR$']
idea {
workspace {
iws.withXml { xmlFile ->
def runManager = xmlFile.asNode().component.find { it.@name == 'RunManager' }
// enable assertions for junit tests
def junitDefaults = runManager.configuration.find { it.@default == 'true' && it.@type == 'JUnit' }
junitDefaults.option.find { it.@name == 'VM_PARAMETERS' }.replaceNode {
option(name: 'VM_PARAMETERS', value: jvmTestFlags.join(' '))
}
// add Crate application configuration
def crateApp = runManager.configuration.find { it.@name == 'Crate' && it.@type == 'Application' }
if (crateApp == null) {
runManager.append(new XmlParser().parse(file("idea/crateApp.xml")))
}
}
}
project {
vcs = 'Git'
ipr {
withXml { provider ->
def node = provider.asNode()
node.append(new XmlParser().parse(file("idea/codeStyle.xml")))
def copyrightManager = node.component.find { it.'@name' == 'CopyrightManager' }
copyrightManager.@default = "CrateASL2"
def aslCopyright = copyrightManager.copyright.find {
it.option.find { it.@name == "myName" }?.@value == "CrateASL2"
}
if (aslCopyright == null) {
copyrightManager.append(new XmlParser().parse(file("idea/copyright.xml")))
}
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '3.1'
}