diff --git a/build.gradle b/build.gradle index 0beeef4..b1681d1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonSlurper + plugins { id "java" id "edu.wpi.first.GradleRIO" version "2024.3.2" @@ -15,6 +17,8 @@ java { def ROBOT_MAIN_CLASS = "frc.robot.Main" +final MAX_JAVA_HEAP_SIZE_MB = 100; + repositories { mavenLocal() mavenCentral() @@ -55,6 +59,15 @@ deploy { // getTargetTypeClass is a shortcut to get the class type using a string frcJava(getArtifactTypeClass('FRCJavaArtifact')) { + jvmArgs.add("-XX:+UnlockExperimentalVMOptions") + + // Set the minimum heap size to the maximum heap size to avoid resizing + jvmArgs.add("-Xmx" + MAX_JAVA_HEAP_SIZE_MB + "M") + jvmArgs.add("-Xms" + MAX_JAVA_HEAP_SIZE_MB + "M") + jvmArgs.add("-XX:GCTimeRatio=5") + jvmArgs.add("-XX:+UseSerialGC") + jvmArgs.add("-XX:MaxGCPauseMillis=50") + jvmArgs.add("-XX:+AlwaysPreTouch") } // Static files artifact @@ -102,7 +115,7 @@ dependencies { testImplementation "org.mockito:mockito-core:5.4.0" testImplementation 'org.mockito:mockito-junit-jupiter:5.4.0' - def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text) + def akitJson = new JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text) annotationProcessor "org.littletonrobotics.akit.junction:junction-autolog:$akitJson.version" }