Skip to content

#270 Add 'standalone' subproject for programs that link against coppercore#271

Open
godmar wants to merge 5 commits into
mainfrom
270-standalone-tests
Open

#270 Add 'standalone' subproject for programs that link against coppercore#271
godmar wants to merge 5 commits into
mainfrom
270-standalone-tests

Conversation

@godmar
Copy link
Copy Markdown
Contributor

@godmar godmar commented May 26, 2026

Summary

Adds a standalone Gradle subproject for running ad-hoc Java programs (classes with a main method) that compile and run 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 (and the OS loader path), so programs that touch native code — WPILib math/HAL or Phoenix devices in simulation — 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.
  • Vendordeps used by the library are mirrored into standalone/vendordeps/ so Phoenix (and friends) are available at compile and runtime.

Usage

# convenience wrapper (quiet; only the program's output)
standalone/run.sh coppercore.standalone.TransformJsonDump

# or via Gradle directly
./gradlew :standalone:run -PmainClass=coppercore.standalone.HelloCopperCore --args="foo bar"

Included

  • standalone/run.sh — convenience wrapper
  • standalone/README.md — how to add and run programs
  • Examples:
    • HelloCopperCore — minimal template (uses coppercore.geometry.Point)
    • TransformJsonDump — serializes a WPILib Transform3d/Transform2d to JSON via the parameter_tools JSON framework

Verification

  • Both examples run successfully; a temporary Phoenix TalonFX sim check compiled, loaded libCTRE_Phoenix6_Sim.so, and initialized the HAL cleanly.
  • :standalone: exposes no publishing tasks; library modules' publish tasks are intact.

🤖 Generated with Claude Code

…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>
@godmar godmar linked an issue May 26, 2026 that may be closed by this pull request
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 standalone subproject with GradleRIO setup, dependencies on all coppercore modules, and a run task that extracts JNI natives for desktop execution.
  • Adds documentation + a run.sh wrapper and two example programs (HelloCopperCore, TransformJsonDump).
  • Updates the multi-project build to include standalone while explicitly preventing it from being published (publishing plugin/config guarded in root build.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.

Comment thread standalone/build.gradle
Comment thread standalone/run.sh Outdated
godmar and others added 3 commits May 26, 2026 15:02
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create the ability to run test programs

2 participants