From 5b8d01f8e58ce488e21d4eb4039da052b73ab969 Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Thu, 19 Sep 2024 09:01:50 -0400 Subject: [PATCH] Add support for epilogue annotations (#744) Add a new dependency group `wpilibAnnotations` Use like `annotationProcessor wpi.java.deps.wpilibAnnotations()` Add epilogue runtime to the general `wpilib()` group --- .../wpi/java/WPIJavaDepsExtension.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/wpi/first/gradlerio/wpi/java/WPIJavaDepsExtension.java b/src/main/java/edu/wpi/first/gradlerio/wpi/java/WPIJavaDepsExtension.java index 387313e5..fc5905ab 100644 --- a/src/main/java/edu/wpi/first/gradlerio/wpi/java/WPIJavaDepsExtension.java +++ b/src/main/java/edu/wpi/first/gradlerio/wpi/java/WPIJavaDepsExtension.java @@ -14,20 +14,24 @@ public class WPIJavaDepsExtension { private final ProviderFactory providers; + private static String dependencyNotation(String groupId, String artifactId, Provider version) { + return groupId + ":" + artifactId + ":" + version.get(); + } + private void createJavaDependencies(String groupdId, String artifactId, Provider version) { wpilibDeps.add(providers.provider(() -> { - return groupdId + ":" + artifactId + ":" + version.get(); + return dependencyNotation(groupdId, artifactId, version); })); wpilibSources.add(providers.provider(() -> { - return groupdId + ":" + artifactId + ":" + version.get() + ":sources"; + return dependencyNotation(groupdId, artifactId, version) + ":sources"; })); } private Provider createJniDependency(String groupdId, String artifactId, Provider version, boolean debug, String platform) { String debugString = debug ? "debug" : ""; return providers.provider(() -> { - return groupdId + ":" + artifactId + ":" + version.get() + ":" + platform + debugString + "@zip"; + return dependencyNotation(groupdId, artifactId, version) + ":" + platform + debugString + "@zip"; }); } @@ -50,6 +54,7 @@ public WPIJavaDepsExtension(WPIVersionsExtension versions, ProviderFactory provi createJavaDependencies("edu.wpi.first.wpiutil", "wpiutil-java", versions.getWpilibVersion()); createJavaDependencies("edu.wpi.first.apriltag", "apriltag-java", versions.getWpilibVersion()); createJavaDependencies("edu.wpi.first.wpiunits", "wpiunits-java", versions.getWpilibVersion()); + createJavaDependencies("edu.wpi.first.epilogue", "epilogue-runtime-java", versions.getWpilibVersion()); createJavaDependencies("edu.wpi.first.thirdparty.frc2024.opencv", "opencv-java", versions.getOpencvVersion()); createJavaDependencies("org.ejml", "ejml-simple", versions.getEjmlVersion()); @@ -65,6 +70,16 @@ public List> wpilib() { return wpilibDeps; } + /** Dependencies required for using WPILib's Java annotations during compilation. */ + public List> wpilibAnnotations() { + // epilogue-runtime is a dependency of epilogue-processor, and needs to be on the annotation processor + // classpath at compile time for the processor to function + return List.of( + providers.provider(() -> dependencyNotation("edu.wpi.first.epilogue", "epilogue-processor-java", versions.getWpilibVersion())), + providers.provider(() -> dependencyNotation("edu.wpi.first.epilogue", "epilogue-runtime-java", versions.getWpilibVersion())) + ); + } + public List> wpilibSources() { return wpilibSources; }