Skip to content

Commit 12f8cf8

Browse files
committed
Merge branch 'production'
2 parents 282d734 + 9cde77a commit 12f8cf8

File tree

11 files changed

+384
-13
lines changed

11 files changed

+384
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ toast/preferences/
1515
run/
1616
libs/groovy-2.4.1.jar
1717
releases/
18+
deploymentScripts/gradle/gradle/wrapper/gradle-wrapper.properties

build.gradle

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,22 @@ class BuildGradle implements Plugin<Project> {
154154
project.task('release', dependsOn: 'build') << {
155155
ant.zip(destfile: "releases/Toast-${project.version}.zip",
156156
basedir: "release")
157-
try {
158-
ant.delete(dir: "build/runnable")
159-
} catch (Exception e) {}
160-
ant.copy(tofile: "build/runnable/Toast.jar") {
161-
ant.fileset(dir: "build/latest/")
162-
}
163-
ant.copy(todir: "build/runnable"){
164-
ant.fileset(dir: "runnableScripts/")
165-
}
166-
ant.zip(destfile: "releases/Toast-${project.version}-RUNNABLE.zip",
167-
basedir: "build/runnable")
157+
try {
158+
ant.delete(dir: "build/runnable")
159+
} catch (Exception e) {}
160+
ant.copy(tofile: "build/runnable/Toast.jar") {
161+
ant.fileset(dir: "build/latest/")
162+
}
163+
ant.copy(todir: "build/runnable"){
164+
ant.fileset(dir: "runnableScripts/")
165+
}
166+
ant.zip(destfile: "releases/Toast-${project.version}-RUNNABLE.zip",
167+
basedir: "build/runnable")
168+
169+
ant.copy(todir: "build/deployment") {
170+
ant.fileset(dir: "deploymentScripts")
171+
}
172+
ant.zip(destfile: "releases/Toast-Deployment-Utility.zip", basedir: "build/deployment")
168173
}
169174
}
170175
}

build.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
toast.version=0.3.0
1+
toast.version=0.5.0
7.34 KB
Binary file not shown.

deploymentScripts/deployToast

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd gradle
3+
gradlew -q combo

deploymentScripts/deployToast.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd gradle
2+
gradlew -q combo
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import org.gradle.logging.StyledTextOutput;
2+
import org.gradle.logging.StyledTextOutputFactory;
3+
import static org.gradle.logging.StyledTextOutput.Style;
4+
5+
apply plugin: Build
6+
7+
class Build implements Plugin<Project> {
8+
def project
9+
def teamNumber
10+
11+
void apply(Project project) {
12+
this.project = project
13+
System.setProperty('org.gradle.color.header', 'CYAN')
14+
15+
project.repositories.add(project.repositories.mavenCentral())
16+
17+
project.getConfigurations().maybeCreate('compile')
18+
19+
def sshAntTask = project.getConfigurations().maybeCreate('sshAntTask')
20+
project.dependencies.add(sshAntTask.name, 'org.apache.ant:ant-jsch:1.7.1')
21+
project.dependencies.add(sshAntTask.name, 'jsch:jsch:0.1.29')
22+
23+
project.ant.taskdef(name: 'scp',
24+
classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
25+
classpath: sshAntTask.asPath)
26+
27+
def dl = project.task('download') << {
28+
String baseURL = "http://dev.sourcecoded.info/jaci/maven/jaci/openrio/toast/Toast";
29+
download("caches/toast", "${baseURL}/maven-metadata.xml", "toast-metadata.xml")
30+
def latest = getLatest()
31+
println "\tLatest Toast version: ${latest}"
32+
download("caches/toast", "${baseURL}/${latest}/Toast-${latest}.jar", "toast.jar")
33+
println "\tToast Download Successful!"
34+
}
35+
36+
def dp = project.task('deploy') << {
37+
if (teamNumber == null) teamNumber = project.team
38+
File file = new File("caches/toast/toast.jar")
39+
if (!file.exists())
40+
throw new Exception("Could not deploy (file not found). Have you tried running 'gradlew download' first?")
41+
try {
42+
deploy(rioHost(project), file)
43+
} catch (Exception e) {
44+
println "\tCould not deploy to Hostname, attempting IP...."
45+
deploy(rioIP(project), file)
46+
}
47+
}
48+
49+
project.task('combo') << {
50+
def out = services.get(StyledTextOutputFactory).create("Toast")
51+
out.withStyle(Style.Header).println "Connect to the internet and hit 'enter' to download Toast!"
52+
System.console().readLine()
53+
dl.execute()
54+
out.withStyle(Style.Header).println "Please enter your Team Number and hit 'enter'"
55+
teamNumber = System.console().readLine("\tTeam Number: ")
56+
out.withStyle(Style.Header).println "Connect to the same network as the RoboRIO and hit 'enter' to deploy Toast!"
57+
System.console().readLine()
58+
dp.execute()
59+
out.withStyle(Style.Header).println "Toast has been deployed to your RoboRIO successfully! Hit 'enter' to continue!"
60+
System.console().readLine()
61+
}
62+
}
63+
64+
String getLatest() {
65+
def xml = new XmlSlurper().parse("caches/toast/toast-metadata.xml").versioning.versions.depthFirst()
66+
return (xml.toList() as Set).last()
67+
}
68+
69+
void download(String dest, String from, String name) {
70+
File output = new File(dest, name)
71+
File f = new File(dest)
72+
f.mkdirs()
73+
def file = new FileOutputStream(output)
74+
def out = new BufferedOutputStream(file)
75+
HttpURLConnection httpcon = new URL(from).openConnection()
76+
httpcon.addRequestProperty("User-Agent", "Toast-Deployment")
77+
out << httpcon.getInputStream()
78+
out.close()
79+
}
80+
81+
void deploy(String host, File source) {
82+
println "\tAttempting to send new code to RoboRIO... ${host}"
83+
84+
project.ant.scp(file: "${source.getAbsolutePath()}",
85+
todir:"lvuser@${host}:FRCUserProgram.jar",
86+
password:"",
87+
port:22,
88+
trust:true)
89+
90+
println "\tDeploy Successful!"
91+
}
92+
93+
String rioHost(Project project) {
94+
return "roboRIO-${teamNumber}.local"
95+
}
96+
97+
String rioIP(Project project) {
98+
String team = teamNumber
99+
int length = team.length();
100+
if (length < 4)
101+
for (int i = 0; i < 4 - length; i++)
102+
team = "0" + team;
103+
104+
return "10." + team.substring(0, 2) + "." + team.substring(2, 4) + ".20"
105+
}
106+
}
49.8 KB
Binary file not shown.

deploymentScripts/gradle/gradlew

Lines changed: 164 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)