Skip to content

Commit bf8a335

Browse files
committed
Update BuildConstantsPublisher JavaDoc to reference the WPILib docs (so it doesn't get stale)
1 parent 9c5bb83 commit bf8a335

2 files changed

Lines changed: 4 additions & 48 deletions

File tree

lib/src/main/java/com/team2813/lib2813/util/BuildConstantsPublisher.java

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,14 @@
2424
*
2525
* <p>To instantiate a BuildConstantsPublisher, a build constants class, {@code BuildConstants}, is
2626
* needs to be generated for the robot library by enabling the `gversion` plugin in the gradle build
27-
* file.
28-
*
29-
* <pre>{@code
30-
* plugins {
31-
* ...
32-
* // Plugin needed for Git Build Info
33-
* // (see https://docs.wpilib.org/en/stable/docs/software/advanced-gradlerio/deploy-git-data.html)
34-
* id 'com.peterabeles.gversion' version '1.10'
35-
* ...
36-
* }
37-
* ...
38-
* // Generates a BuildConstants file.
39-
* // https://docs.wpilib.org/en/stable/docs/software/advanced-gradlerio/deploy-git-data.html
40-
* project.compileJava.dependsOn(createVersionFile)
41-
* def BUILD_CONSTANTS_AUTOGEN_PATH = 'build/generated/sources/build_constants/'
42-
* gversion {
43-
* // Build inside build/ (so that it will be ignored by git due to .gitignore)
44-
* // and inside build/generated/ (so that it will be ignored by our Spotless
45-
* // rules).
46-
* srcDir = BUILD_CONSTANTS_AUTOGEN_PATH
47-
* classPackage = 'com.team2813'
48-
* className = 'BuildConstants'
49-
* dateFormat = 'yyyy-MM-dd HH:mm:ss z'
50-
* timeZone = 'America/Los_Angeles' // Use preferred time zone
51-
* indent = ' '
52-
* }
53-
* sourceSets.main.java.srcDirs += BUILD_CONSTANTS_AUTOGEN_PATH
54-
* ...
55-
* }</pre>
27+
* file. Instructions can be found <a
28+
* href="https://docs.wpilib.org/en/stable/docs/software/advanced-gradlerio/deploy-git-data.html">in
29+
* the WPILib documentation</a>.
5630
*
5731
* <p>With the BuildConstants generation enabled, the publisher is initialized and used like this:
5832
*
5933
* <pre>{@code
60-
* BuildConstantsPublisher buildConstantsPublisher(com.team2813.BuildConstants.class);
34+
* BuildConstantsPublisher buildConstantsPublisher(frc.robot.BuildConstants.class);
6135
* // Publish the build constants to "/Metadata" on the NetworkTables
6236
* buildConstantsPublisher.publish(NetworkTableInstance.getDefault());
6337
* // Log the build constants in the robot console as well.

lib/src/main/java/com/team2813/lib2813/util/BuildConstantsRecord.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,4 @@ String gitSubmitTimeString() {
6868
String buildTimeString() {
6969
return DATE_FORMATTER.format(buildTime);
7070
}
71-
72-
private static ZonedDateTime extractZonedDateTime(Class<?> buildConstantsClass, String fieldName)
73-
throws NoSuchFieldException, IllegalAccessException {
74-
String value = (String) buildConstantsClass.getDeclaredField(fieldName).get(null);
75-
try {
76-
return ZonedDateTime.parse(value, DATE_FORMATTER);
77-
} catch (DateTimeParseException e) {
78-
String message =
79-
"Could not extract build constants from "
80-
+ buildConstantsClass.getSimpleName()
81-
+ " due to unparsable date-time value for "
82-
+ fieldName
83-
+ ": "
84-
+ e.getMessage();
85-
DriverStation.reportWarning(message, e.getStackTrace());
86-
return null;
87-
}
88-
}
8971
}

0 commit comments

Comments
 (0)