This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
198 lines (165 loc) · 6.35 KB
/
build.gradle.kts
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import edu.wpi.first.deployutils.deploy.artifact.FileTreeArtifact
import edu.wpi.first.gradlerio.GradleRIOPlugin
import edu.wpi.first.gradlerio.deploy.roborio.FRCJavaArtifact
import edu.wpi.first.gradlerio.deploy.roborio.RoboRIO
import edu.wpi.first.toolchain.NativePlatforms
import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
java
idea
kotlin("jvm")
id("com.google.devtools.ksp")
id("edu.wpi.first.GradleRIO") version "2024.3.2"
id("com.peterabeles.gversion") version "1.10"
}
val javaVersion = 17
val robotMainClass = "com.frcteam3636.frc2024.Main"
allprojects {
plugins.apply("java")
plugins.apply("org.jetbrains.kotlin.jvm")
java {
val version = JavaVersion.toVersion(javaVersion)
sourceCompatibility = version
targetCompatibility = version
}
kotlin {
compilerOptions {
// https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support
jvmTarget = JvmTarget.fromTarget(javaVersion.toString())
jvmToolchain(javaVersion)
}
}
repositories {
maven {
url = uri("https://maven.pkg.github.com/Mechanical-Advantage/AdvantageKit")
credentials {
username = "Mechanical-Advantage-Bot"
password =
"\u0067\u0068\u0070\u005f\u006e\u0056\u0051\u006a\u0055\u004f\u004c\u0061\u0079\u0066\u006e\u0078\u006e\u0037\u0051\u0049\u0054\u0042\u0032\u004c\u004a\u006d\u0055\u0070\u0073\u0031\u006d\u0037\u004c\u005a\u0030\u0076\u0062\u0070\u0063\u0051"
}
}
mavenLocal()
mavenCentral()
}
}
gversion {
srcDir = layout.buildDirectory.dir("generated/gversion/main/kotlin").get().toString()
language = "kotlin"
classPackage = "com.frcteam3636.version"
dateFormat = "yyyy-MM-dd HH:mm:ss z"
timeZone = "America/Los_Angeles" // Use preferred time zone
indent = " "
}
// Define the targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project DeployUtils.
deploy {
targets {
val roborio by register<RoboRIO>("roborio") {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
team = frc.getTeamOrDefault(3636)
debug = frc.getDebugOrDefault(false)
}
roborio.artifacts {
register<FRCJavaArtifact>("frcJava") {
jvmArgs.add("-ea") // Remove this flag during comp to disable asserts
setJarTask(tasks.jar)
dependsOn(tasks.assemble)
}
register<FileTreeArtifact>("frcStaticFileDeploy") {
files = project.fileTree("src/main/deploy")
directory = "/home/lvuser/deploy"
}
}
}
}
configurations.configureEach {
exclude(group = "edu.wpi.first.wpilibj")
}
wpi {
with(java) {
// Set to true to use debug for JNI.
debugJni = false
// Configure jar and deploy tasks
configureExecutableTasks(tasks.jar.get())
configureTestTasks(tasks.test.get())
}
// Simulation configuration (e.g. environment variables).
with(sim) {
addGui().defaultEnabled = true
addDriverstation().defaultEnabled = true
}
}
dependencies {
wpi.java.deps.wpilib().forEach { implementation(it) }
wpi.java.vendor.java().forEach { implementation(it) }
wpi.java.deps.wpilibJniDebug(NativePlatforms.roborio).forEach { "roborioDebug"(it) }
wpi.java.vendor.jniDebug(NativePlatforms.roborio).forEach { "roborioDebug"(it) }
wpi.java.deps.wpilibJniRelease(NativePlatforms.roborio).forEach { "roborioRelease"(it) }
wpi.java.vendor.jniRelease(NativePlatforms.roborio).forEach { "roborioRelease"(it) }
wpi.java.deps.wpilibJniDebug(NativePlatforms.desktop).forEach { nativeDebug(it) }
wpi.java.vendor.jniDebug(NativePlatforms.desktop).forEach { nativeDebug(it) }
wpi.sim.enableDebug().forEach { simulationDebug(it) }
wpi.java.deps.wpilibJniRelease(NativePlatforms.desktop).forEach { nativeRelease(it) }
wpi.java.vendor.jniRelease(NativePlatforms.desktop).forEach { nativeRelease(it) }
wpi.sim.enableRelease().forEach { simulationRelease(it) }
implementation(project(":annotation"))
ksp(project(":annotation"))
// testImplementation(platform("io.kotest:kotest-bom:5.8.0"))
// testImplementation("io.kotest:kotest-runner-junit5")
// testImplementation("io.kotest:kotest-assertions-core")
// testImplementation("io.mockk:mockk:1.13.9")
}
// Set up the JAR File. In this case, adding all libraries into the main jar ('fat jar')
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
tasks {
jar {
group = "build"
manifest(GradleRIOPlugin.javaManifest(robotMainClass))
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from({
configurations
.runtimeClasspath
.get()
.map { if (it.isDirectory) it else zipTree(it) }
})
}
test {
useJUnitPlatform()
}
// This check is buggy, also it seems to be removed in AdvantageKit 2025
// val checkAkitInstall by register<JavaExec>("checkAkitInstall") {
// dependsOn("classes")
// mainClass = "org.littletonrobotics.junction.CheckInstall"
// classpath = sourceSets.main.get().runtimeClasspath
// }
compileKotlin {
dependsOn(createVersionFile)
// finalizedBy(checkAkitInstall)
}
register<Exec>("cleanStaticFiles") {
commandLine = listOf("ssh", "[email protected]", "rm", "-rf", "/home/lvuser/deploy")
}
}
sourceSets {
main {
kotlin {
srcDir(gversion.srcDir)
}
}
}
idea {
project {
// The project.sourceCompatibility setting is not always picked up, so we set explicitly
languageLevel = IdeaLanguageLevel(javaVersion)
}
module {
// Improve development & (especially) debugging experience (and IDEA's capabilities) by having libraries' source & javadoc attached
isDownloadJavadoc = true
isDownloadSources = true
// Exclude the .vscode directory from indexing and search
excludeDirs.add(file(".vscode"))
}
}