1
1
plugins {
2
2
id " java"
3
3
id " edu.wpi.first.GradleRIO" version " 2022.4.1"
4
+ id " com.diffplug.spotless" version " 5.10.2"
4
5
}
5
6
6
7
allprojects {
@@ -9,74 +10,107 @@ allprojects {
9
10
}
10
11
}
11
12
13
+ // Set this to the latest version of StuyLib.
14
+ // You can check here: https://github.com/StuyPulse/StuyLib/releases.
15
+ final String STUYLIB_VERSION = ' v2022.4.0'
16
+
17
+ def ROBOT_MAIN_CLASS = " com.stuypulse.robot.Main"
18
+
12
19
sourceCompatibility = JavaVersion . VERSION_11
13
20
targetCompatibility = JavaVersion . VERSION_11
14
21
15
- def ROBOT_MAIN_CLASS = " com.stuypulse.robot.Main"
16
- final String STUYLIB_VERSION = ' v2022.3.0'
17
22
18
23
// Define my targets (RoboRIO) and artifacts (deployable files)
19
- // This is added by GradleRIO's backing project EmbeddedTools .
24
+ // This is added by GradleRIO's backing project DeployUtils .
20
25
deploy {
21
26
targets {
22
- roboRIO(" roborio" ) {
27
+ // roborio("roborio") {
28
+ roborio(getTargetTypeClass(' RoboRIO' )) {
23
29
// Team number is loaded either from the .wpilib/wpilib_preferences.json
24
30
// or from command line. If not found an exception will be thrown.
25
31
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
26
32
// want to store a team number in this file.
27
- team = frc. getTeamNumber()
28
- }
29
- }
30
- artifacts {
31
- frcJavaArtifact( ' frcJava ' ) {
32
- targets << " roborio "
33
- // Debug can be overridden by command line, for use with VSCode
34
- debug = frc . getDebugOrDefault( false )
35
- }
36
- // Built in artifact to deploy arbitrary files to the roboRIO.
37
- fileTreeArtifact( ' frcStaticFileDeploy ' ) {
38
- // The directory below is the local directory to deploy
39
- files = fileTree(dir : ' src/main/deploy' )
40
- // Deploy to RoboRIO target, into /home/lvuser/deploy
41
- targets << " roborio "
42
- directory = ' /home/lvuser/deploy '
33
+ team = project . frc. getTeamNumber()
34
+ debug = project . frc . getDebugOrDefault( false )
35
+
36
+ artifacts {
37
+ // First part is artifact name, 2nd is artifact type
38
+ // getTargetTypeClass is a shortcut to get the class type using a string
39
+
40
+ frcJava(getArtifactTypeClass( ' FRCJavaArtifact ' )) {
41
+ }
42
+
43
+ // Static files artifact
44
+ frcStaticFileDeploy(getArtifactTypeClass( ' FileTreeArtifact ' )) {
45
+ files = project . fileTree(' src/main/deploy' )
46
+ directory = ' /home/lvuser/deploy'
47
+ }
48
+ }
43
49
}
44
50
}
45
51
}
46
52
53
+ def deployArtifact = deploy. targets. roborio. artifacts. frcJava
54
+
55
+ // Set to true to use debug for JNI.
56
+ wpi. java. debugJni = false
57
+
47
58
// Set this to true to enable desktop support.
48
- def includeDesktopSupport = true
59
+ def includeDesktopSupport = false
49
60
50
61
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
51
62
// Also defines JUnit 4.
52
63
dependencies {
53
- implementation wpi. deps. wpilib()
54
- nativeZip wpi. deps. wpilibJni(wpi. platforms. roborio)
55
- nativeDesktopZip wpi. deps. wpilibJni(wpi. platforms. desktop)
64
+ implementation wpi. java. deps. wpilib()
65
+ implementation wpi. java. vendor. java()
56
66
67
+ roborioDebug wpi. java. deps. wpilibJniDebug(wpi. platforms. roborio)
68
+ roborioDebug wpi. java. vendor. jniDebug(wpi. platforms. roborio)
57
69
58
- implementation wpi. deps. vendor. java()
59
- nativeZip wpi. deps. vendor. jni(wpi. platforms. roborio)
60
- nativeDesktopZip wpi. deps. vendor. jni(wpi. platforms. desktop)
70
+ roborioRelease wpi. java. deps. wpilibJniRelease(wpi. platforms. roborio)
71
+ roborioRelease wpi. java. vendor. jniRelease(wpi. platforms. roborio)
61
72
62
- testImplementation ' junit:junit:4.12'
73
+ nativeDebug wpi. java. deps. wpilibJniDebug(wpi. platforms. desktop)
74
+ nativeDebug wpi. java. vendor. jniDebug(wpi. platforms. desktop)
75
+ simulationDebug wpi. sim. enableDebug()
63
76
64
- // Enable simulation gui support. Must check the box in vscode to enable support
65
- // upon debugging
66
- simulation wpi. deps. sim. gui(wpi. platforms. desktop, false )
67
- simulation wpi. deps. sim. driverstation(wpi. platforms. desktop, false )
77
+ nativeRelease wpi. java. deps. wpilibJniRelease(wpi. platforms. desktop)
78
+ nativeRelease wpi. java. vendor. jniRelease(wpi. platforms. desktop)
79
+ simulationRelease wpi. sim. enableRelease()
68
80
69
- // Websocket extensions require additional configuration.
70
- // simulation wpi.deps.sim.ws_server(wpi.platforms.desktop, false)
71
- // simulation wpi.deps.sim.ws_client(wpi.platforms.desktop, false)
81
+ testImplementation ' junit:junit:4.12'
72
82
73
- compile " com.github.StuyPulse:StuyLib:${ STUYLIB_VERSION} " ;
83
+ implementation " com.github.StuyPulse:StuyLib:${ STUYLIB_VERSION} " ;
74
84
}
75
85
76
86
// Simulation configuration (e.g. environment variables).
77
- sim {
78
- // Sets the websocket client remote host.
79
- // envVar "HALSIMWS_HOST", "10.0.0.2"
87
+ wpi. sim. addGui(). defaultEnabled = false
88
+ wpi. sim. addDriverstation()
89
+
90
+ spotless {
91
+ enforceCheck = false
92
+ java {
93
+ targetExclude(" src/main/java/com/stuypulse/robot/commands/autons/*.java" )
94
+ licenseHeaderFile " LICENSE"
95
+
96
+ googleJavaFormat(). aosp()
97
+
98
+ trimTrailingWhitespace()
99
+ endWithNewline()
100
+
101
+ importOrder(
102
+ ' com.stuypulse.stuylib' ,
103
+ ' com.stuypulse.constants' ,
104
+ ' com.stuypulse.subsystems' ,
105
+ ' com.stuypulse.commands' ,
106
+ ' com.stuypulse.commands.auton' ,
107
+ ' com.stuypulse.util' ,
108
+ ' com.stuypulse' ,
109
+ ' edu.wpi' ,
110
+ ' com.revrobotics'
111
+ )
112
+ removeUnusedImports()
113
+ }
80
114
}
81
115
82
116
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
@@ -85,4 +119,10 @@ sim {
85
119
jar {
86
120
from { configurations. runtimeClasspath. collect { it. isDirectory() ? it : zipTree(it) } }
87
121
manifest edu.wpi.first.gradlerio.GradleRIOPlugin . javaManifest(ROBOT_MAIN_CLASS )
122
+ duplicatesStrategy = DuplicatesStrategy . INCLUDE
88
123
}
124
+
125
+ // Configure jar and deploy tasks
126
+ deployArtifact. jarTask = jar
127
+ wpi. java. configureExecutableTasks(jar)
128
+ wpi. java. configureTestTasks(test)
0 commit comments