#270 Add 'standalone' subproject for programs that link against coppercore#271
Open
godmar wants to merge 5 commits into
Open
#270 Add 'standalone' subproject for programs that link against coppercore#271godmar wants to merge 5 commits into
godmar wants to merge 5 commits into
Conversation
…rcore Adds a 'standalone' Gradle subproject for running ad-hoc Java programs (with main methods) against the coppercore library modules, WPILib, AdvantageKit, and vendordeps (e.g. CTRE Phoenix). The 'run' task extracts WPILib and vendordep JNI natives onto java.library.path so programs that touch native code work from the command line. standalone is never published or bundled: the publishing plugin is guarded off for it in the root build.gradle and no library module depends on it, so building and publishing coppercore is unaffected. Includes a run.sh convenience wrapper, a README, and two example programs: HelloCopperCore and TransformJsonDump (serializes Transform2d/3d via the parameter_tools JSON framework). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
GradleRIO reads vendordeps at plugin-apply time, so a config-time copy in the build body ran too late and a committed standalone/vendordeps/Phoenix6.json was needed for the first build. That committed copy was a second source of truth that had to be kept in sync by hand. Instead, resolve GradleRIO with apply(false), mirror the library modules' */vendordeps/*.json into standalone's git-ignored vendordeps/ dir, then apply GradleRIO. The mirror runs every build so it can never drift; the directory is no longer committed. A copy (not a symlink) is used so it aggregates any number of modules and works on every platform. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new standalone Gradle subproject intended for running ad-hoc Java main programs against the coppercore modules plus WPILib/AdvantageKit/vendordeps, including a custom :standalone:run task and a convenience wrapper script.
Changes:
- Introduces the
standalonesubproject with GradleRIO setup, dependencies on all coppercore modules, and aruntask that extracts JNI natives for desktop execution. - Adds documentation + a
run.shwrapper and two example programs (HelloCopperCore,TransformJsonDump). - Updates the multi-project build to include
standalonewhile explicitly preventing it from being published (publishing plugin/config guarded in rootbuild.gradle).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
standalone/src/main/java/coppercore/standalone/TransformJsonDump.java |
Example program demonstrating JSON serialization of WPILib transforms via coppercore JSON tooling. |
standalone/src/main/java/coppercore/standalone/HelloCopperCore.java |
Minimal “hello world” style example using a coppercore module type. |
standalone/run.sh |
Convenience wrapper for invoking :standalone:run with a selected main class. |
standalone/README.md |
User documentation for adding/running standalone programs and how vendordeps are mirrored. |
standalone/build.gradle |
Core build logic for the new subproject (dependencies, native extraction, run task, vendordep mirroring). |
standalone/.gitignore |
Ignores generated vendordeps and local simulation artifacts under the subproject. |
settings.gradle |
Includes the new standalone subproject in the Gradle multi-project build. |
build.gradle |
Guards publishing plugin/config so standalone is never published. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
copy { ... } runs immediately during the configuration phase (not as a task), causing filesystem writes every time Gradle configures the build (even when running unrelated tasks). This is unfriendly to Gradle configuration caching and can add overhead to every CI/dev invocation. Consider moving this into a dedicated task (e.g., Sync/Copy) and wiring it as an explicit dependency of the tasks that need it, or otherwise gating the copy/apply behavior so it only runs when :standalone tasks are requested.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
as per CoPilot Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… requested The previous gating applied GradleRIO only when a :standalone task was named, but the rest of build.gradle used the `wpi` extension unconditionally, so configuring the project during any other build (e.g. CI's `./gradlew build`) failed with "unknown property 'wpi'". GradleRIO reads vendordeps at apply (configuration) time, so the mirror copy cannot be deferred to a task; and standalone is otherwise pulled into the aggregate build. So instead of half-gating, fully skip configuration when no :standalone task is requested: disable this project's tasks and return early. This keeps standalone out of `./gradlew build` (it can no longer break the library build/publish) while still avoiding config-time filesystem writes for unrelated builds. Verified: unrelated tasks, aggregate build, and :standalone:run/build all pass locally. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
standaloneGradle subproject for running ad-hoc Java programs (classes with amainmethod) that compile and run against the coppercore library modules, WPILib, AdvantageKit, and vendordeps (e.g. CTRE Phoenix).runtask extracts WPILib and vendordep JNI natives ontojava.library.path(and the OS loader path), so programs that touch native code — WPILib math/HAL or Phoenix devices in simulation — work from the command line.standaloneis never published or bundled: the publishing plugin is guarded off for it in the rootbuild.gradle, and no library module depends on it, so building and publishing coppercore is unaffected.standalone/vendordeps/so Phoenix (and friends) are available at compile and runtime.Usage
Included
standalone/run.sh— convenience wrapperstandalone/README.md— how to add and run programsHelloCopperCore— minimal template (usescoppercore.geometry.Point)TransformJsonDump— serializes a WPILibTransform3d/Transform2dto JSON via theparameter_toolsJSON frameworkVerification
TalonFXsim check compiled, loadedlibCTRE_Phoenix6_Sim.so, and initialized the HAL cleanly.:standalone:exposes no publishing tasks; library modules' publish tasks are intact.🤖 Generated with Claude Code