11buildscript {
2- repositories { jcenter() }
2+ repositories {
3+ jcenter()
4+ maven {
5+ url " https://plugins.gradle.org/m2/"
6+ }
7+ }
38
49 dependencies {
510 classpath ' com.netflix.nebula:gradle-aggregate-javadocs-plugin:2.2.+'
11+ classpath ' net.ltgt.gradle:gradle-errorprone-plugin:0.0.8'
612 }
713}
814plugins {
@@ -15,10 +21,78 @@ plugins {
1521}
1622apply plugin : ' nebula-aggregate-javadocs'
1723
24+ def getGitCommit = { ->
25+ String HEAD_REF = new File (rootDir, ' .git/HEAD' ). text. replace(" ref: " , " " ). replace(" \n " , " " )
26+ String COMMIT_HASH = new File (rootDir, " .git/${ HEAD_REF} " ). text. substring(0 , 7 )
27+ return COMMIT_HASH
28+ }
29+
30+ idea. project {
31+ ipr. withXml { provider ->
32+ def node = provider. asNode()
33+ def compilerConfig = node. component. find { it. ' @name' == ' CompilerConfiguration' }
34+ compilerConfig. annotationProcessing[0 ]. ' @enabled' = ' true'
35+ // def ccfg = node.component.find { it.@name == 'CompilerConfiguration' }
36+ // ccfg.remove(ccfg.annotationProcessing)
37+ // ccfg.append(new NodeBuilder().annotationProcessing() {
38+ // profile(default: true, name: 'Default', enabled: true) {
39+ // processorPath(useClasspath: true)
40+ // }
41+ // })
42+ }
43+ }
44+
45+ /*
46+ * Gets the version name from the latest Git tag
47+ * http://ryanharter.com/blog/2013/07/30/automatic-versioning-with-git-and-gradle/
48+ */
49+ def getVersionName = { ->
50+ if (project. hasProperty(" vers" )) return vers
51+ try {
52+ def stdout = new ByteArrayOutputStream ()
53+ exec {
54+ commandLine ' git' , ' describe' , ' --tags'
55+ standardOutput = stdout
56+ }
57+ return stdout. toString(). trim(). substring(1 )
58+ } catch (org.gradle.process.internal.ExecException e) {
59+ if (! new File (rootDir, ' .git/HEAD' ). exists()) {
60+ println (" WARN: Could not fetch Git Tag for build version. No Git HEAD available. Substituting version 0.0.0" )
61+ return " 0.0.0"
62+ }
63+ 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." )
64+ return getGitCommit()
65+ }
66+ }
67+
68+ def getVersionSimple = { ->
69+ if (project. hasProperty(" vers" )) return vers
70+ try {
71+ def stdout = new ByteArrayOutputStream ()
72+ exec {
73+ commandLine ' git' , ' describe' , ' --tags' , ' --abbrev=0'
74+ standardOutput = stdout
75+ }
76+ return stdout. toString(). trim(). substring(1 )
77+ } catch (org.gradle.process.internal.ExecException e) {
78+ if (! new File (rootDir, ' .git/HEAD' ). exists()) {
79+ println (" WARN: Could not fetch Git Tag for build version. No Git HEAD available. Substituting version 0.0.0" )
80+ return " 0.0.0"
81+ }
82+ 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." )
83+ return getGitCommit()
84+ }
85+ }
86+
1887allprojects {
1988 apply plugin : ' java'
2089 apply plugin : ' application'
2190 apply plugin : ' jacoco'
91+ apply plugin : ' net.ltgt.errorprone'
92+
93+ configurations. errorprone {
94+ resolutionStrategy. force ' com.google.errorprone:error_prone_core:2.0.8'
95+ }
2296
2397
2498 repositories {
@@ -34,9 +108,11 @@ allprojects {
34108 testCompile group : ' net.jodah' , name : ' concurrentunit' , version : ' 0.4.2'
35109 testCompile group : ' org.hamcrest' , name : ' hamcrest-all' , version : ' 1.3'
36110 testCompile group : ' junit' , name : ' junit' , version : ' 4.12'
111+ testCompile group : ' com.google.truth' , name : ' truth' , version : ' 0.28'
112+ testCompile group : ' com.google.guava' , name : ' guava-testlib' , version : ' 19.0'
37113 }
38114
39- version = ' 0.3.0 '
115+ version = getVersionName()
40116
41117 compileJava {
42118 options. compilerArgs << " -g"
@@ -76,7 +152,8 @@ allprojects {
76152 }
77153}
78154
79- def os = osdetector. classifier. replace(" osx" , " macosx" ). replace(" windows-x86_32" , " windows-x86" )
155+ def os = osdetector. classifier. replace(" osx" , " macosx" ). replace(" x86_32" , " x86" )
156+ def arch = osdetector. arch. replace(" x86_64" , " x64" )
80157
81158project(" :core" ) {
82159 apply plugin : ' java'
@@ -91,10 +168,17 @@ project(":core") {
91168 repositories {
92169 flatDir {
93170 dirs ' libs'
171+ maven {
172+ url = " http://first.wpi.edu/FRC/roborio/maven/development"
173+ }
174+ maven {
175+ url = " https://github.com/WPIRoboticsProjects/rosjava_mvn_repo/raw/master"
176+ }
94177 }
95178 }
96179
97180 dependencies {
181+ compile group : ' com.google.code.findbugs' , name : ' jsr305' , version : ' 3.0.1'
98182 compile group : ' org.bytedeco' , name : ' javacv' , version : ' 1.1'
99183 compile group : ' org.bytedeco.javacpp-presets' , name : ' opencv' , version : ' 3.0.0-1.1'
100184 compile group : ' org.bytedeco.javacpp-presets' , name : ' opencv' , version : ' 3.0.0-1.1' , classifier : os
@@ -103,9 +187,19 @@ project(":core") {
103187 compile group : ' org.python' , name : ' jython' , version : ' 2.7.0'
104188 compile group : ' com.thoughtworks.xstream' , name : ' xstream' , version : ' 1.4.8'
105189 compile group : ' org.apache.commons' , name : ' commons-lang3' , version : ' 3.4'
106- compile group : ' com.google.guava' , name : ' guava' , version : ' 18.0'
107- compile group : ' com.google.inject' , name : ' guice' , version : ' 4.0'
190+ compile group : ' com.google.guava' , name : ' guava' , version : ' 19.0'
191+ compile group : ' com.google.auto.value' , name : ' auto-value' , version : ' 1.1'
192+ // We use the no_aop version of Guice because the aop isn't avaiable in arm java
193+ // http://stackoverflow.com/a/15235190/3708426
194+ // https://github.com/google/guice/wiki/OptionalAOP
195+ compile group : ' com.google.inject' , name : ' guice' , version : ' 4.0' , classifier : ' no_aop'
108196 compile group : ' com.google.inject.extensions' , name : ' guice-assistedinject' , version : ' 4.0'
197+
198+ // Network publishing dependencies
199+ compile group : ' org.ros.rosjava_core' , name : ' rosjava' , version : ' [0.2,0.3)'
200+ compile group : ' org.ros.rosjava_messages' , name : ' grip_msgs' , version : ' 0.0.1'
201+ compile group : ' edu.wpi.first.wpilib.networktables.java' , name : ' NetworkTables' , version : ' 3.0.0-SNAPSHOT' , classifier : ' desktop'
202+ compile group : ' edu.wpi.first.wpilib.networktables.java' , name : ' NetworkTables' , version : ' 3.0.0-SNAPSHOT' , classifier : ' arm'
109203 }
110204
111205 mainClassName = ' edu.wpi.grip.core.Main'
@@ -172,8 +266,8 @@ project(":core") {
172266
173267 idea. module {
174268 sourceDirs + = sourceSets. generated. java. srcDirs
269+ sourceDirs + = file(' generated' )
175270 }
176- // End IDE setup
177271}
178272
179273project(" :ui" ) {
@@ -191,9 +285,7 @@ project(":ui") {
191285 compile project(path : ' :core' , configuration : ' shadow' )
192286 ideProvider project(path : ' :core' , configuration : ' compile' )
193287 compile group : ' org.controlsfx' , name : ' controlsfx' , version : ' 8.40.10'
194- compile group : ' org.apache.ant' , name : ' ant-jsch' , version : ' 1.8.1'
195- compile group : ' com.jcabi' , name : ' jcabi-ssh' , version : ' 1.5'
196- compile group : ' org.jdeferred' , name : ' jdeferred-core' , version : ' 1.2.4'
288+ compile group : ' com.hierynomus' , name : ' sshj' , version : ' 0.15.0'
197289 testCompile files(project(' :core' ). sourceSets. test. output. classesDir)
198290 testCompile files(project(' :core' ). sourceSets. test. output. resourcesDir)
199291 testCompile group : ' org.testfx' , name : ' testfx-core' , version : ' 4.0.+'
@@ -208,9 +300,19 @@ project(":ui") {
208300 }
209301
210302 javafx {
303+ profiles {
304+ linux {
305+ category = ' Development'
306+ bundleArguments = [
307+ // for DEB bundles
308+ ' email' :
' [email protected] ' ,
// This is the email used for the deb maintainer field. 309+ ]
310+ }
311+ }
211312 appID = ' GRIP'
212313 appName = ' GRIP'
213314 mainClass = " edu.wpi.grip.ui.Main"
315+ version = getVersionSimple()
214316
215317 // This prevents the JIT from eating stack traces that get thrown a lot
216318 // This is slower but means we actually get the stack traces instead of
@@ -220,6 +322,16 @@ project(":ui") {
220322 jvmArgs = [" -XX:-OmitStackTraceInFastThrow" ]
221323 }
222324 mainClassName = javafx. mainClass
325+
326+ // The JavaFX plugin does not provide a way to change the installer artifact's name without changing the appName or appID,
327+ // so instead, we simply rename the artifact to append the architecture (x86 or x64)
328+ jfxDeploy. doLast {
329+ def filet = fileTree(dir : ' build/distributions' , include : " ${ javafx.appName} -${ getVersionSimple()} .*" )
330+ filet. each { File f ->
331+ def f2 = new File (f. getParentFile(), " ${ f.getName().replace("${getVersionSimple()}", "${getVersionSimple()}-${arch}")} " )
332+ f. renameTo(f2)
333+ }
334+ }
223335}
224336
225337/*
0 commit comments