-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
155 lines (124 loc) · 3.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
buildscript{
ext.kotlin_version = "1.1.4-3"
ext.ssh_version = "2.9.0"
repositories {
maven {
url "https://plugins.gradle.org/m2"
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
classpath "org.hidetake:gradle-ssh-plugin:${ssh_version}"
}
}
group 'Technomancers'
version '1.0-SNAPSHOT'
ext.networktable_verion = "3.1.7"
ext.opencv_version = "3.1.0"
ext.cscore_version = "1.0.2"
/*
You must clean before building as you may get the wrong native libraries in the zip.
*/
/*
BuildTypes
use -PbuildType=
windows
linux
arm-raspbian
arm
armhf
*/
/*
NTServer
use -PntServer=
For debugging purposes please specify which server a Network Tables server is on.
*/
if (!project.hasProperty("buildType")) {
ext.buildType = "arm-raspbian"
}
if (!project.hasProperty("piHost")) {
ext.piHost = "technopi.local"
}
if (!project.hasProperty("piUser")) {
ext.piUser = "pi"
}
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.hidetake.ssh'
apply plugin: 'application'
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
apply from: "dependencies.gradle"
repositories {
mavenCentral()
maven {
url "http://first.wpi.edu/FRC/roborio/maven/release"
}
}
configurations {
nativeBundle
}
dependencies {
compile ntcoreDep()
compile cscoreDep()
compile "org.opencv:opencv-java:${opencv_version}"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:${kotlin_version}"
nativeBundle opencvJNIDep()
}
mainClassName = 'edu.frc.technomancers.VisionServer.MainKt'
jar {
baseName = rootProject.name
}
applicationDefaultJvmArgs.push('-Djava.library.path=MY_APP_HOME/native')
if (project.hasProperty("ntServer")) {
applicationDefaultJvmArgs.push("-Dnetworktable.server=${ntServer}")
}
remotes {
pi {
host = piHost
user = piUser
identity = file("$rootDir/ssh/id_rsa")
knownHosts = allowAnyHosts
}
}
task extractNative(type: Copy) {
from zipTree(configurations.nativeBundle.singleFile)
into "$buildDir/nativeLibs"
}
applicationDistribution.from(extractNative) {
exclude "META-INF"
exclude "**/MANIFEST.MF"
into 'native/'
}
applicationDistribution.from("$rootDir/LICENSE")
distZip.dependsOn extractNative
distTar.dependsOn extractNative
run.dependsOn extractNative
run {
doFirst {
applicationDefaultJvmArgs.push("-Djava.library.path=$buildDir/nativeLibs")
}
}
startScripts {
doLast {
unixScript.text = unixScript.text.replace('MY_APP_HOME', '\$APP_HOME')
windowsScript.text = windowsScript.text.replace('MY_APP_HOME', '%APP_HOME%')
}
}
task deploy {
doLast {
def f = files(distZip).first()
def fName = f.name.take(f.name.lastIndexOf('.'))
ssh.run {
session(remotes.pi) {
put from: f, into: "."
execute "sudo systemctl stop VisionServer && unzip -o ${f.name} && ln -sf $fName VisionServer && sudo systemctl start VisionServer"
}
}
}
}
deploy.group = "distribution"
deploy.dependsOn distZip