-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
128 lines (112 loc) · 3.74 KB
/
Copy pathbuild.gradle
File metadata and controls
128 lines (112 loc) · 3.74 KB
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
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2021.2.2"
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/frc-862/lightning"
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
}
}
}
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
def ROBOT_MAIN_CLASS = "frc.robot.Main"
deploy {
targets {
roboRIO("roborio") {
team = frc.getTeamNumber()
}
}
artifacts {
frcJavaArtifact('frcJava') {
targets << "roborio"
debug = frc.getDebugOrDefault(false)
}
fileTreeArtifact('frcStaticFileDeploy') {
files = fileTree(dir: 'src/main/deploy')
targets << "roborio"
directory = '/home/lvuser/deploy'
}
}
}
tasks.register("update_version") {
def versionPropsFile = file('src/main/resources/version.properties')
def versionBuild
def gitHash
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '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 getGitStatus = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'status'
standardOutput = stdout
}
return stdout.toString().trim()
}
doLast {
mkdir("src/main/resources")
ant.touch(file:"src/main/resources/version.properties")
if (versionPropsFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
if (versionProps['VERSION_BUILD'] == null) {
versionBuild = 1
} else {
versionBuild = versionProps['VERSION_BUILD'].toInteger() + 1
}
versionProps['VERSION_BUILD'] = versionBuild.toString()
gitHash = getGitHash()
versionProps['GIT_HASH'] = gitHash
versionProps['GIT_BRANCH'] = getGitBranch()
versionProps['BUILD_TIME'] = (new Date()).toString()
versionProps['BUILD_STATUS'] = getGitStatus()
versionProps.store(versionPropsFile.newWriter(), null)
} else {
throw new FileNotFoundException("Could not read version.properties!")
}
}
}
tasks.named("deploy") {
dependsOn("update_version")
}
def includeDesktopSupport = false
dependencies {
implementation wpi.deps.wpilib()
nativeZip wpi.deps.wpilibJni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.wpilibJni(wpi.platforms.desktop)
implementation wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:3.2.4'
simulation wpi.deps.sim.gui(wpi.platforms.desktop, false)
simulation wpi.deps.sim.driverstation(wpi.platforms.desktop, false)
implementation 'frc:lightning:0.0.0-beta1'
}
// Simulation configuration (e.g. environment variables).
sim {
// Sets the websocket client remote host.
// envVar "HALSIMWS_HOST", "10.0.0.2"
}
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
}