Skip to content

Add offline jdt2jar CLI and distroless packaging#148

Merged
simbo1905 merged 9 commits into
mainfrom
copilot/add-jdt2jar-cli-container
May 20, 2026
Merged

Add offline jdt2jar CLI and distroless packaging#148
simbo1905 merged 9 commits into
mainfrom
copilot/add-jdt2jar-cli-container

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

The JTD codegen path now has an offline packaging flow that turns a schema into a standalone validator JAR at build time. The repo also ships a minimal distroless container for running the compiler without a full JDK in the final image.

What changed

  • Added a new jdt2jar module with a shaded CLI that:
    • accepts a JTD schema file
    • emits a standalone validator JAR
    • supports --output, --package, --class, --main, and --include-sources
  • Added runtime support for embedded validator execution via a java -jar entrypoint.
  • Added a build-stage helper that derives a slim jlink runtime and packages it into the container image.
  • Added focused integration coverage for JAR contents, CLI validation flow, and source emission.
  • Wired the module into the JDK 24+ codegen profile and added repo-level packaging docs.
jdt2jar user.jtd.json --output user-validator.jar --main --include-sources
java -jar user-validator.jar --validate payload.json

Why this change is needed

  • Removes the JDK 24+ runtime dependency from the generated validator path.
  • Makes validator generation CI-friendly and containerizable.
  • Provides a small, reproducible runtime image for ephemeral build/validation jobs.

How were these changes tested

  • Focused module tests and packaging checks were exercised locally.

Checklist

  • Code builds / passes tests
  • New tests added if needed
  • Update to use CODING_STYLE_LLM.md convensions
  • Documentation updated if needed
  • AGENTS.md updated if appropriate

Copilot AI and others added 3 commits May 20, 2026 07:42
Copilot AI changed the title [WIP] Add jdt2jar: offline JTD-to-JAR compiler CLI and minimal distroless container Add offline jdt2jar CLI and distroless packaging May 20, 2026
Copilot AI requested a review from simbo1905 May 20, 2026 07:52
…d CI Docker builds

- Move Dockerfile from repo root to jdt2jar/ (built with -f jdt2jar/Dockerfile .)
- Add jdt2jar/.dockerignore to exclude build artifacts
- Rewrite jdt2jar/README.md with full Docker/GHCR usage instructions
- Update root README.md to signpost to jdt2jar submodule for optional tool
- Add docker-build job to ci.yml (Java 25, smoke test)
- Add docker-build job to maven.yml (Java 25, smoke test after tests pass)
- Add docker-publish job to release-on-tag.yml (pushes version + latest to ghcr.io)
- Release notes now include Docker image pull commands

How to verify:
  docker build -t jdt2jar -f jdt2jar/Dockerfile .
  docker run --rm jdt2jar --help
@simbo1905 simbo1905 marked this pull request as ready for review May 20, 2026 10:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc652d4f79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread jdt2jar/.dockerignore
@@ -0,0 +1,21 @@
# Build outputs
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move Docker ignore rules to active build context

This ignore file is never applied by the current CI/release Docker builds because they invoke docker build with context: . (repository root), and Docker only reads .dockerignore from the context root (or a Dockerfile.dockerignore companion). As a result, large/sensitive files (for example .git/, .env, and local artifacts) are still sent in build context despite being listed here, which increases build time and can leak unintended content into remote builders.

Useful? React with 👍 / 👎.


private static Path sourcePathFor(Path output) {
final var name = output.getFileName().toString();
final var sourceName = name.endsWith(".jar") ? name.substring(0, name.length() - 4) + ".java" : name + ".java";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Derive companion source filename from class name

The --include-sources output path is computed from the JAR filename (widget-validator.java) instead of the generated public class name (WidgetValidator), so the emitted source is not directly compilable: javac fails with “public class ... should be declared in a file named ...”. This breaks the advertised source-emission workflow whenever --class differs from the output JAR basename.

Useful? React with 👍 / 👎.

simbo1905 added 3 commits May 20, 2026 11:23
- Root README: module table distinguishes interpreter (infrequent config) vs codegen (hot-path)
- json-java21-jtd/README: documents config-parsing use case, links to codegen
- json-java21-jtd-codegen/README: documents hot-path use case, links to interpreter
- jdt2jar/README: documents build-time pre-compilation bridging both paths
- All three sub-READMEs note JDK incubator future direction
- Interpreter module (json-java21-jtd): JtdValidator.compileInterpreter() replaces deprecated compile()
- Codegen module (json-java21-jtd-codegen): new JtdValidator.compileGenerated() in own package
- Generated bytecode implements json.java21.jtd.codegen.JtdValidator (not interpreter's interface)
- ValidatorMain uses codegen's JtdValidator for generated validators
- Jdt2Jar bundles codegen's JtdValidator.class in output JARs
- All tests updated to use new method names
- pom.xml: -Werror + showDeprecation across all modules
- READMEs updated with clear two-path guidance

How to verify:
  jenv local 21 && ./mvnw test -pl json-java21-jtd -am
  jenv local 25 && ./mvnw test -pl json-java21-jtd,json-java21-jtd-codegen -am
@simbo1905 simbo1905 merged commit 49c6f51 into main May 20, 2026
7 checks passed
@simbo1905 simbo1905 deleted the copilot/add-jdt2jar-cli-container branch May 20, 2026 11:01
simbo1905 added a commit that referenced this pull request May 20, 2026
simbo1905 added a commit that referenced this pull request May 21, 2026
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.

jdt2jar: offline JTD-to-JAR compiler CLI + minimal distroless container

2 participants