|
| 1 | +plugins { |
| 2 | + id "java" |
| 3 | + id "edu.wpi.first.GradleRIO" version "2023.1.1-beta-4" |
| 4 | +} |
| 5 | + |
| 6 | +sourceCompatibility = JavaVersion.VERSION_11 |
| 7 | +targetCompatibility = JavaVersion.VERSION_11 |
| 8 | + |
| 9 | +def ROBOT_MAIN_CLASS = "frc.robot.Main" |
| 10 | + |
| 11 | +// Define my targets (RoboRIO) and artifacts (deployable files) |
| 12 | +// This is added by GradleRIO's backing project DeployUtils. |
| 13 | +deploy { |
| 14 | + targets { |
| 15 | + roborio(getTargetTypeClass('RoboRIO')) { |
| 16 | + // Team number is loaded either from the .wpilib/wpilib_preferences.json |
| 17 | + // or from command line. If not found an exception will be thrown. |
| 18 | + // You can use getTeamOrDefault(team) instead of getTeamNumber if you |
| 19 | + // want to store a team number in this file. |
| 20 | + team = project.frc.getTeamNumber() |
| 21 | + debug = project.frc.getDebugOrDefault(false) |
| 22 | + |
| 23 | + artifacts { |
| 24 | + // First part is artifact name, 2nd is artifact type |
| 25 | + // getTargetTypeClass is a shortcut to get the class type using a string |
| 26 | + |
| 27 | + frcJava(getArtifactTypeClass('FRCJavaArtifact')) { |
| 28 | + } |
| 29 | + |
| 30 | + // Static files artifact |
| 31 | + frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { |
| 32 | + files = project.fileTree('src/main/deploy') |
| 33 | + directory = '/home/lvuser/deploy' |
| 34 | + } |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +def deployArtifact = deploy.targets.roborio.artifacts.frcJava |
| 41 | + |
| 42 | +// Set to true to use debug for JNI. |
| 43 | +wpi.java.debugJni = false |
| 44 | + |
| 45 | +// Set this to true to enable desktop support. |
| 46 | +def includeDesktopSupport = false |
| 47 | + |
| 48 | +// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. |
| 49 | +// Also defines JUnit 5. |
| 50 | +dependencies { |
| 51 | + implementation wpi.java.deps.wpilib() |
| 52 | + implementation wpi.java.vendor.java() |
| 53 | + |
| 54 | + roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio) |
| 55 | + roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio) |
| 56 | + |
| 57 | + roborioRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.roborio) |
| 58 | + roborioRelease wpi.java.vendor.jniRelease(wpi.platforms.roborio) |
| 59 | + |
| 60 | + nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop) |
| 61 | + nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop) |
| 62 | + simulationDebug wpi.sim.enableDebug() |
| 63 | + |
| 64 | + nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop) |
| 65 | + nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop) |
| 66 | + simulationRelease wpi.sim.enableRelease() |
| 67 | + |
| 68 | + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2' |
| 69 | + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2' |
| 70 | + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2' |
| 71 | +} |
| 72 | + |
| 73 | +test { |
| 74 | + useJUnitPlatform() |
| 75 | + systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' |
| 76 | +} |
| 77 | + |
| 78 | +// Simulation configuration (e.g. environment variables). |
| 79 | +wpi.sim.addGui().defaultEnabled = true |
| 80 | +wpi.sim.addDriverstation() |
| 81 | + |
| 82 | +// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') |
| 83 | +// in order to make them all available at runtime. Also adding the manifest so WPILib |
| 84 | +// knows where to look for our Robot Class. |
| 85 | +jar { |
| 86 | + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } |
| 87 | + manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) |
| 88 | + duplicatesStrategy = DuplicatesStrategy.INCLUDE |
| 89 | +} |
| 90 | + |
| 91 | +// Configure jar and deploy tasks |
| 92 | +deployArtifact.jarTask = jar |
| 93 | +wpi.java.configureExecutableTasks(jar) |
| 94 | +wpi.java.configureTestTasks(test) |
| 95 | + |
| 96 | +// Configure string concat to always inline compile |
| 97 | +tasks.withType(JavaCompile) { |
| 98 | + options.compilerArgs.add '-XDstringConcat=inline' |
| 99 | +} |
0 commit comments