-
Notifications
You must be signed in to change notification settings - Fork 46
/
build.gradle
312 lines (260 loc) · 10.6 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
/* Gradle's build script */
buildscript {
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.0'
classpath 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.2'
classpath 'org.owasp:dependency-check-gradle:1.4.5'
}
}
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import com.github.jengelman.gradle.plugins.shadow.transformers.ApacheLicenseResourceTransformer
import com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormat
import com.github.sherter.googlejavaformatgradleplugin.VerifyGoogleJavaFormat
plugins {
id 'java' // or 'groovy' Must be explicitly applied
id 'com.github.johnrengelman.shadow' version '1.2.3'
id 'com.github.ben-manes.versions' version '0.15.0'
}
/* This project uses Java and Eclipse. */
apply plugin: "java"
apply plugin: "eclipse"
/* Coveralls with JaCoCo */
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
/* Maven shade plugin equivalent */
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.github.sherter.google-java-format'
apply plugin: 'org.owasp.dependencycheck'
/* Set up group and version info for myria */
archivesBaseName = "myria"
group = "edu.washington.escience.myria"
version = "0.1"
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
}
/* We use Java 1.8 */
sourceCompatibility = 1.8
targetCompatibility = 1.8
/* Use Java 8 -parameters option for Jackson Parameter Names module */
compileJava.options.compilerArgs.add '-parameters'
compileTestJava.options.compilerArgs.add '-parameters'
/* Tell gradle where the source code is located. */
sourceSets {
/* Code for main */
main {
java.srcDir 'src'
java.srcDir 'protobuf/java'
java.srcDir 'third-party-src'
resources.srcDir 'conf'
output.classesDir = 'build/main'
}
/* Code for tests */
test {
java.srcDir 'test'
output.classesDir = 'build/test'
}
}
/* Build the Eclipse .classpath file first, because if Gradle's build fails
* we'll want to use Eclipse to debug it. */
test.dependsOn eclipseClasspath
tasks.eclipseClasspath.dependsOn cleanEclipseClasspath
task format(type: GoogleJavaFormat) {
source 'src'
source 'test'
include '**/*.java'
}
task verifyFormatting(type: VerifyGoogleJavaFormat) {
source 'src'
source 'test'
include '**/*.java'
}
/* Test if all *.java have been formatted. Run ./gradlew format to format all */
test.dependsOn verifyFormatting
/*
* List the compile and runtime dependencies of all the tests.
* Note that "group:name:version" dependencies will be downloaded from Maven.
*/
/* Where we will fetch external JAR files from. */
repositories {
flatDir {
name 'localRepository'
}
/* For local REEF builds installed in the local Maven repo. */
/* mavenLocal() */
/* Our custom Hadoop jars, in case we need to backport a fix */
/* maven { url "https://raw.github.com/uwescience/hadoop/mvn-repo" } */
/* Our private maven repo for our REEF fork */
maven { url "https://raw.github.com/uwescience/reef/mvn-repo" }
/* Apache snapshot repo, for REEF dev builds */
/* maven { url "http://repository.apache.org/snapshots/" } */
maven { url "http://clojars.org/repo" } /* Clojars, for MonetDB */
mavenCentral() /* The standard Java Maven repository. */
}
repositories.localRepository {
dirs './lib'
}
/* List constants that we use in multiple places. */
ext.slf4jVersion = "1.7.9"
ext.jacksonVersion = "2.4.4"
ext.jerseyVersion = "2.14"
ext.swaggerVersion = "2.11"
ext.swaggerMinorVersion = "1.3.11"
ext.jmxetricsVersion = "1.0.8"
/* for local or development REEF builds */
/* ext.reefVersion = "0.17.0-SNAPSHOT" */
ext.reefVersion = "0.16.0"
ext.hadoopVersion = "2.8.1"
dependencies {
/* Note this jar is fetched from our private Maven repo (patched for HADOOP-12807) */
compile ("org.apache.hadoop:hadoop-aws:${hadoopVersion}") {
exclude group: "com.sun.jersey"
}
compile ("org.apache.hadoop:hadoop-client:${hadoopVersion}") {
/* Hadoop depends on Jersey 1 but we don't need it. Exclude it to prevent
* Classloader picking the wrong version of Jersey classes. */
exclude group: "com.sun.jersey"
}
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.184'
compile "xerces:xercesImpl:2.11.0"
compile "xalan:xalan:2.7.2"
compile "com.google.code.findbugs:annotations:3.0.0"
compile "net.jcip:jcip-annotations:1.0"
compile "org.ini4j:ini4j:0.5.2"
compile "com.almworks.sqlite4java:sqlite4java:1.0.392"
compile "com.google.guava:guava:18.0"
/* this version is required for compatibility with REEF */
compile "com.google.protobuf:protobuf-java:2.5.0"
compile "io.netty:netty:3.9.6.Final"
compile 'org.eclipse.collections:eclipse-collections-api:8.2.0'
compile 'org.eclipse.collections:eclipse-collections:8.2.0'
compile "joda-time:joda-time:2.6"
compile "commons-io:commons-io:2.4"
compile "org.apache.commons:commons-lang3:3.3.2"
compile "commons-cli:commons-cli:1.2"
compile "org.glassfish.jersey.core:jersey-server:${jerseyVersion}"
compile "org.glassfish.jersey.core:jersey-client:${jerseyVersion}"
compile "org.glassfish.jersey.core:jersey-common:${jerseyVersion}"
compile "org.glassfish.jersey.containers:jersey-container-grizzly2-http:${jerseyVersion}"
compile "org.glassfish.jersey.media:jersey-media-multipart:${jerseyVersion}"
compile "org.glassfish.jersey.media:jersey-media-json-jackson:${jerseyVersion}"
compile "javax.annotation:javax.annotation-api:1.2"
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-providers:${jacksonVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:${jacksonVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-guava:${jacksonVersion}"
compile "com.wordnik:swagger-jersey2-jaxrs_${swaggerVersion}:${swaggerMinorVersion}"
compile "org.slf4j:slf4j-api:${slf4jVersion}"
//runtime "org.slf4j:slf4j-simple:${slf4jVersion}"
runtime "org.slf4j:slf4j-log4j12:${slf4jVersion}"
runtime "info.ganglia.jmxetric:jmxetric:${jmxetricsVersion}"
compile "org.apache.commons:commons-csv:1.1"
compile "commons-httpclient:commons-httpclient:3.1"
// Expression compiler
compile "org.codehaus.janino:janino:2.7.7"
compile "org.postgresql:postgresql:9.4-1202-jdbc41"
compile("org.apache.reef:reef-project:${reefVersion}") { changing = true }
compile("org.apache.reef:reef-common:${reefVersion}") { changing = true }
compile("org.apache.reef:reef-runtime-local:${reefVersion}") { changing = true }
compile("org.apache.reef:reef-runtime-yarn:${reefVersion}") { changing = true }
compile("org.apache.reef:wake:${reefVersion}") { changing = true }
compile("org.apache.reef:tang:${reefVersion}") { changing = true }
testCompile "junit:junit:4.12"
testCompile "org.assertj:assertj-core:1.7.1"
testCompile "com.carrotsearch:junit-benchmarks:0.7.2"
}
/* Tell Java to emit all compiler warnings. */
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint"
}
/* Tell all tasks to add sqlite library to their classpath when running. */
tasks.withType(Test) {
systemProperty "java.library.path", file("lib/sqlite4java-392")
getReports().getHtml().setDestination(file('build/reports/'+name))
// set heap size for the test JVM(s)
minHeapSize = "512m"
maxHeapSize = "2048m"
}
/* The eclipseClasspath task will build a local Eclipse .classpath file. */
eclipse.classpath {
/* Ensure Eclipse compiled output appears in build directory. */
defaultOutputDir = file('build/main')
/* Download library sources and Javadoc for use in debugging. */
downloadSources = true
downloadJavadoc = true
file {
/* Ugly hack to stick the JNI pointer for sqlite into the .classpath file. */
withXml {
provider ->
provider.asNode().findAll { it.@path.contains("sqlite") }.each {
it.children().each {
it.appendNode('attribute', [name: 'org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY', value:'myria/lib/sqlite4java-392'])
}
}
}
/* Separate output folder for each src folders*/
whenMerged {
cp ->
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("src") }*.output = "build/main"
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("protobuf") }*.output = "build/main"
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("third-party-src") }*.output = "build/main"
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("test") }*.output = "build/test"
}
}
}
tasks.withType(Test) {
/* Optional: uncomment the next line to print which test is running. Useful for debugging. */
beforeTest { desc -> println "Executing test ${desc.name} [${desc.className}]" }
testLogging { exceptionFormat = 'full' }
}
/*
* Copy all the jars that this project depends on into `build/libs`, and make
* sure it this happens whenever jar is run.
*/
task copyToLib(type: Copy) {
into "${buildDir}/libs"
from configurations.runtime
}
/* Hack to make code that specifies this jar in JVM options version-agnostic */
task symlinkMetricsJar << {
ant.symlink(link: "${buildDir}/libs/jmxetric.jar", resource: "jmxetric-${jmxetricsVersion}.jar", overwrite: true)
}
tasks.symlinkMetricsJar.dependsOn copyToLib
tasks.jar.dependsOn symlinkMetricsJar
/* allTests just runs all tests */
task allTests
allTests.dependsOn test
/* Assemble the Myria jar into `build/libs` */
jar {
manifest {
attributes("Implementation-Title" : "Myria",
"Implementation-Version": version)
}
}
/* Build the uberjar containing all our dependencies */
shadowJar {
/* Without this option: "org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries." */
zip64 true
/* Apache license files will cause weird issues on case-insensitive filesystems like Mac HFS */
exclude "LICENSE", "META-INF/*.RSA", "META-INF/*.SF","META-INF/*.DSA", "META-INF/license"
transform(ApacheLicenseResourceTransformer)
/* merge service descriptors to avoid Hadoop FileSystem services shadowing each other */
mergeServiceFiles()
/* Some of our deps conflict with old versions in Hadoop distro */
relocate 'com.google.common', 'myriadeps.com.google.common'
relocate 'javax.ws.rs', 'myriadeps.javax.ws.rs'
relocate 'com.fasterxml.jackson', 'myriadeps.com.fasterxml.jackson'
relocate 'org.glassfish.jersey', 'myriadeps.org.glassfish.jersey'
}
/* Coveralls */
jacocoTestReport {
executionData(test)
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
/* Update the version and branch in constants.java. */
task updateCommitInfo(type:Exec) {
commandLine './update_commit_id.sh'
}
compileJava.dependsOn updateCommitInfo
eclipseClasspath.dependsOn updateCommitInfo