forked from WPIRoboticsProjects/GRIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
385 lines (337 loc) · 14 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:2.2.+'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.8'
}
}
plugins {
id 'java'
id 'idea'
id 'eclipse'
id 'jacoco'
id 'com.google.osdetector' version '1.4.0'
id 'com.github.johnrengelman.shadow' version '1.2.3'
}
apply plugin: 'nebula-aggregate-javadocs'
def getGitCommit = { ->
String HEAD_REF = new File(rootDir, '.git/HEAD').text.replace("ref: ", "").replace("\n", "")
String COMMIT_HASH = new File(rootDir, ".git/${HEAD_REF}").text.substring(0, 7)
return COMMIT_HASH
}
idea.project {
ipr.withXml { provider ->
def node = provider.asNode()
def compilerConfig = node.component.find { it.'@name' == 'CompilerConfiguration'}
compilerConfig.annotationProcessing[0].'@enabled' = 'true'
// def ccfg = node.component.find { it.@name == 'CompilerConfiguration' }
// ccfg.remove(ccfg.annotationProcessing)
// ccfg.append(new NodeBuilder().annotationProcessing() {
// profile(default: true, name: 'Default', enabled: true) {
// processorPath(useClasspath: true)
// }
// })
}
}
/*
* Gets the version name from the latest Git tag
* http://ryanharter.com/blog/2013/07/30/automatic-versioning-with-git-and-gradle/
*/
def getVersionName = { ->
if (project.hasProperty("vers")) return vers
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim().substring(1)
} catch (org.gradle.process.internal.ExecException e) {
if (!new File(rootDir, '.git/HEAD').exists()) {
println("WARN: Could not fetch Git Tag for build version. No Git HEAD available. Substituting version 0.0.0")
return "0.0.0"
}
println("WARN: Could not fetch Git Tag for build version. Please install Git and add it to your PATH. For now, the Git commit hash has been substituted.")
return getGitCommit()
}
}
def getVersionSimple = { ->
if (project.hasProperty("vers")) return vers
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--abbrev=0'
standardOutput = stdout
}
return stdout.toString().trim().substring(1)
} catch (org.gradle.process.internal.ExecException e) {
if (!new File(rootDir, '.git/HEAD').exists()) {
println("WARN: Could not fetch Git Tag for build version. No Git HEAD available. Substituting version 0.0.0")
return "0.0.0"
}
println("WARN: Could not fetch Git Tag for build version. Please install Git and add it to your PATH. For now, the Git commit hash has been substituted.")
return getGitCommit()
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'jacoco'
apply plugin: 'net.ltgt.errorprone'
configurations.errorprone {
resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.9'
}
repositories {
mavenCentral()
jcenter()
}
jacoco {
toolVersion = "0.7.5.201505241946"
}
dependencies {
testCompile group: 'net.jodah', name: 'concurrentunit', version: '0.4.2'
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'com.google.truth', name: 'truth', version: '0.28'
testCompile group: 'com.google.guava', name: 'guava-testlib', version: '19.0'
}
version = getVersionName()
compileJava {
options.compilerArgs << "-g"
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
check.dependsOn jacocoTestReport
tasks.withType(Javadoc) {
source compileJava.source
options.addStringOption('Xdoclint:all,-html', '-quiet')
failOnError false
}
tasks.withType(JavaExec) {
enableAssertions = true
}
// Turn on test results
test {
testLogging {
if (project.hasProperty('logTests')) {
events "started", "passed", "skipped", "failed"
} else {
events "failed"
}
exceptionFormat "full"
}
doFirst {
filter.includePatterns.each {
include "${it.replaceAll('\\.', "\\${File.separator}")}.class"
}
filter.setIncludePatterns('*')
}
}
}
def os = osdetector.classifier.replace("osx", "macosx").replace("x86_32", "x86")
def arch = osdetector.arch.replace("x86_64", "x64")
project(":core") {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: "com.github.johnrengelman.shadow"
configurations {
shadow
// I'm not sure what's going on here, but this works
// https://github.com/bytedeco/javacv/issues/395
all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
}
repositories {
flatDir {
dirs 'libs'
}
maven {
url = "http://first.wpi.edu/FRC/roborio/maven/development"
}
maven {
url = "https://github.com/WPIRoboticsProjects/rosjava_mvn_repo/raw/master"
}
}
dependencies {
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
compile group: 'org.bytedeco', name: 'javacv', version: '1.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.1.0-1.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.1.0-1.2', classifier: os
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.1.0-1.2', classifier: 'linux-armhf'
// I can uncomment this once someone rebuilds the opencv javacpp-presets for frc.
// I was having trouble installing the frc toolchain on xenial, so that means for now you can't deploy to the rio
//compile group: 'org.bytedeco.javacpp-presets', name: 'opencv-3.1.0-1.2', classifier: 'linux-frc'
compile group: 'org.bytedeco.javacpp-presets', name: 'videoinput', version: '0.200-1.2', classifier: os
compile group: 'org.python', name: 'jython', version: '2.7.0'
compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.8'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'com.google.guava', name: 'guava', version: '19.0'
compile group: 'com.google.auto.value', name: 'auto-value', version: '1.1'
// We use the no_aop version of Guice because the aop isn't avaiable in arm java
// http://stackoverflow.com/a/15235190/3708426
// https://github.com/google/guice/wiki/OptionalAOP
compile group: 'com.google.inject', name: 'guice', version: '4.0', classifier: 'no_aop'
compile group: 'com.google.inject.extensions', name: 'guice-assistedinject', version: '4.0'
// Network publishing dependencies
compile group: 'org.ros.rosjava_core', name: 'rosjava', version: '[0.2,0.3)'
compile group: 'org.ros.rosjava_messages', name: 'grip_msgs', version: '0.0.1'
compile group: 'edu.wpi.first.wpilib.networktables.java', name: 'NetworkTables', version: '3.0.0-SNAPSHOT', classifier: 'desktop'
compile group: 'edu.wpi.first.wpilib.networktables.java', name: 'NetworkTables', version: '3.0.0-SNAPSHOT', classifier: 'arm'
}
mainClassName = 'edu.wpi.grip.core.Main'
jar {
manifest {
attributes 'Implementation-Version': version, 'Main-Class': mainClassName
}
}
shadowJar {
artifacts {
shadow(tasks.shadowJar.archivePath) {
builtBy shadowJar
}
}
/* The icudt54b directory in Jython takes up 9 megabytes and doesn't seem to do anything useful. */
exclude 'org/python/icu/impl/data/icudt54b/'
/* We don't use all of the OpenCV libraries, and they seem to take up a lot of space. If we ever decide to
use any more of these (or perhaps just include them for people to use from Python scripts), the following lines
should be changed, but for now this saves us a lot of space. */
exclude 'org/bytedeco/javacpp/*/*calib3d*'
exclude 'org/bytedeco/javacpp/*/*face*'
exclude 'org/bytedeco/javacpp/*/*objdetect*'
exclude 'org/bytedeco/javacpp/*/*optflow*'
exclude 'org/bytedeco/javacpp/*/*photo*'
exclude 'org/bytedeco/javacpp/*/*shape*'
exclude 'org/bytedeco/javacpp/*/*stitching*'
exclude 'org/bytedeco/javacpp/*/*superres*'
exclude 'org/bytedeco/javacpp/*/*videostab*'
exclude 'org/bytedeco/javacpp/*/*xfeatures2d*'
}
sourceSets {
generated {
java {
/* Note: When referencing this it becomes `srcDirs` */
srcDir 'src/generated/java'
}
}
}
task generateCodeFromSource(type: CodeGenerator) {
description 'Generates the Operation Wrappers for the OpenCV methods.\n To skip run with parm `-PskipGenerate`'
dest sourceSets.generated.java.srcDirs
removeExisting true
}
generateCodeFromSource.onlyIf { !project.hasProperty('skipGenerate') }
compileJava.source sourceSets.generated.java, sourceSets.main.java
compileJava.dependsOn generateCodeFromSource
// IDE setup
eclipse.classpath {
file.whenMerged { cp ->
sourceSets.generated.java.srcDirs.forEach { srcDir ->
def source_folder = new org.gradle.plugins.ide.eclipse.model.SourceFolder(srcDir.getAbsolutePath(), "build/classes/merged")
if (cp.entries.find() { it.path == source_folder.path } == null)
cp.entries.add(source_folder)
}
}
}
idea.module {
sourceDirs += sourceSets.generated.java.srcDirs
sourceDirs += file('generated')
}
}
project(":ui") {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'application'
apply from: 'http://dl.bintray.com/shemnon/javafx-gradle/8.1.1/javafx.plugin'
configurations {
ideProvider
}
dependencies {
compile project(path: ':core', configuration: 'shadow')
ideProvider project(path: ':core', configuration: 'compile')
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.10'
compile group: 'com.hierynomus', name: 'sshj', version: '0.15.0'
testCompile files(project(':core').sourceSets.test.output.classesDir)
testCompile files(project(':core').sourceSets.test.output.resourcesDir)
testCompile group: 'org.testfx', name: 'testfx-core', version: '4.0.+'
testCompile group: 'org.testfx', name: 'testfx-junit', version: '4.0.+'
testRuntime group: 'org.testfx', name: 'openjfx-monocle', version: '1.8.0_20'
}
evaluationDependsOn(':core')
compileTestJava.dependsOn tasks.getByPath(':core:testClasses')
idea.module {
scopes.PROVIDED.plus += [configurations.ideProvider]
}
/*
* Allows you to run the UI tests in headless mode by calling gradle with the -Pheadless=true argument
*/
if (project.hasProperty('headless') && project.headless) {
println "Running UI Tests Headless"
test {
jvmArgs = ['-Djava.awt.headless=true', '-Dtestfx.robot=glass', '-Dtestfx.headless=true', '-Dprism.order=sw', '-Dprism.text=t2k']
}
}
javafx {
profiles {
linux {
category = 'Development'
bundleArguments = [
// for DEB bundles
'email': '[email protected]', // This is the email used for the deb maintainer field.
]
}
}
appID = 'GRIP'
appName = 'GRIP'
mainClass = "edu.wpi.grip.ui.Main"
version = getVersionSimple()
// This prevents the JIT from eating stack traces that get thrown a lot
// This is slower but means we actually get the stack traces instead of
// having them become one line like `java.lang.ArrayIndexOutOfBoundsException`
// and as such, would be useless.
// See: https://plumbr.eu/blog/java/on-a-quest-for-missing-stacktraces
jvmArgs = ["-XX:-OmitStackTraceInFastThrow"]
}
mainClassName = javafx.mainClass
// The JavaFX plugin does not provide a way to change the installer artifact's name without changing the appName or appID,
// so instead, we simply rename the artifact to append the architecture (x86 or x64)
jfxDeploy.doLast {
def filet = fileTree(dir: 'build/distributions', include: "${javafx.appName}-${getVersionSimple()}.*")
filet.each { File f ->
def f2 = new File(f.getParentFile(), "${f.getName().replace("${getVersionSimple()}", "${getVersionSimple()}-${arch}")}")
f.renameTo(f2)
}
}
}
/*
* This is roughly based upon this post:
* https://discuss.gradle.org/t/merge-jacoco-coverage-reports-for-multiproject-setups/12100/6
*/
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn(subprojects.test)
additionalSourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
check.dependsOn jacocoRootReport
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}