forked from crate/crate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
209 lines (173 loc) · 5.54 KB
/
Copy pathbuild.gradle
File metadata and controls
209 lines (173 loc) · 5.54 KB
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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.3.1'
}
}
plugins {
id "com.github.kt3k.coveralls" version "2.3.1"
}
allprojects {
apply plugin: 'idea'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
tasks.withType(JavaCompile) {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}
tasks.withType(Test) {
// allow to set the number of test forks from the CLI
if (project.hasProperty('testForks')) {
maxParallelForks = project.testForks as int
}
}
jacoco {
toolVersion = "0.7.1.201405082137"
}
group = 'io.crate'
repositories {
mavenCentral()
}
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
}
}
configure(subprojects.findAll {it.name != 'es'}) {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
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'
}
}
coveralls {
def tmpSources = []
jacocoProjects().each {
evaluationDependsOn(it.name)
if (it.plugins.withType(JavaPlugin) && it.tasks.withType(Test)) {
tmpSources << it.sourceSets.main.allSource.srcDirs.flatten()
}
}
sourceDirs = files(tmpSources).files.absolutePath
jacocoReportPath = "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
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 testingNode = node.component.orderEntry.find {
it.@'module-name' == 'testing'
}
if (testingNode != null) {
def parent = testingNode.parent()
def newNode = new Node(parent, testingNode.name(), testingNode.attributes())
parent.remove(testingNode)
parent.children().add(4, newNode)
}
}
}
}
}
}
def jvmTestFlags = ['-ea']
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(' '))
}
}
}
project {
languageLevel = 'JDK_1_7'
ipr {
withXml { provider ->
def node = provider.asNode()
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("copyright.xml")))
}
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}