-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplash.gradle
101 lines (90 loc) · 3.14 KB
/
splash.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
import java.text.SimpleDateFormat
// Functions to write output to Splash Screen info
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "log", "-n", "1", "--oneline", "--decorate", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
}
def getGitBranch = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim()
}
def getGitFilesChanged = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "diff", "--name-only", "HEAD"
standardOutput = stdout
}
return stdout.toString().trim().replace("\n", ", ").replace("src/main/java/frc/robot/", "")
}
def getGitRemote = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "remote", "--verbose"
standardOutput = stdout
}
return stdout.toString().trim().replace("\n", ", ").replace("src/main/java/frc/robot/", "")
}
task versionTxt() {
String resourcesDir = "$projectDir/src/main/resources"
doFirst {
new File("$resourcesDir/branch.txt").text = "Empty"
new File("$resourcesDir/commit.txt").text = "Empty"
new File("$resourcesDir/changes.txt").text = "Empty"
new File("$resourcesDir/remote.txt").text = "Empty"
new File("$resourcesDir/buildtime.txt").text = "Empty"
}
doLast {
new File("$resourcesDir/branch.txt").text = getGitBranch()
new File("$resourcesDir/commit.txt").text = getGitHash()
new File("$resourcesDir/changes.txt").text = getGitFilesChanged()
new File("$resourcesDir/remote.txt").text = getGitRemote()
new File("$resourcesDir/buildtime.txt").text =
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())
}
}
task deployHost() {
String deployDir = "$projectDir/src/main/deploy"
doFirst {
new File("$deployDir/deployhost.txt").text = "Empty"
new File("$deployDir/deploytime.txt").text = "Empty"
}
doLast {
String deploy_host = ""
try {
deploy_host = java.net.InetAddress.getLocalHost().getHostName()
} catch (all) {
deploy_host = "unknown"
}
new File("$deployDir/deployhost.txt").text = deploy_host
new File("$deployDir/deploytime.txt").text =
new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date())
}
}
task ensureResources() {
doLast {
String resourcesDir = "$projectDir/src/main/resources"
mkdir "$resourcesDir"
}
}
build.dependsOn versionTxt
tasks.getByName('versionTxt').dependsOn(ensureResources)
tasks.getByName('deploy').dependsOn(deployHost)
tasks.getByName('simulateExternalJava').dependsOn(deployHost)
// Remove the next two sections if you don't want Oblog and the halsim_ds_socket plugin.
dependencies {
implementation 'com.github.Oblarg.Oblog:lib:3.1.0'
simulation "edu.wpi.first.halsim:halsim_ds_socket:${wpi.wpilibVersion}:${wpi.platforms.desktop}@zip"
}
repositories {
maven {
url 'https://jitpack.io'
}
}