forked from WPIRoboticsProjects/GRIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
304 lines (261 loc) · 10.2 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
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:2.2.+'
}
}
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.2'
}
apply plugin: 'nebula-aggregate-javadocs'
/*
* Gets the version name from the latest Git tag
* http://ryanharter.com/blog/2013/07/30/automatic-versioning-with-git-and-gradle/
*/
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim().substring(1)
}
def getVersionSimple = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--abbrev=0'
standardOutput = stdout
}
return stdout.toString().trim().substring(1)
}
allprojects {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'jacoco'
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 {
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
}
repositories {
flatDir {
dirs 'libs'
maven {
url = "http://first.wpi.edu/FRC/roborio/maven/development"
}
}
}
dependencies {
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
compile group: 'org.bytedeco', name: 'javacv', version: '1.1'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1', classifier: os
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv-3.0.0-1.1', classifier: 'linux-frc'
compile group: 'org.bytedeco.javacpp-presets', name: 'videoinput', version: '0.200-1.1', 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'
// 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'
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
}
// End IDE setup
}
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.+'
}
evaluationDependsOn(':core')
compileTestJava.dependsOn tasks.getByPath(':core:testClasses')
idea.module {
scopes.PROVIDED.plus += [configurations.ideProvider]
}
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.10'
}