Skip to content

feat: support executing .jar#4625

Merged
suzuki-shunsuke merged 4 commits into
mainfrom
feat-support-jar
Mar 11, 2026
Merged

feat: support executing .jar#4625
suzuki-shunsuke merged 4 commits into
mainfrom
feat-support-jar

Conversation

@suzuki-shunsuke

@suzuki-shunsuke suzuki-shunsuke commented Mar 11, 2026

Copy link
Copy Markdown
Member

Close #4623

If aqua which returns a jar file, aqua executes it via java -jar.

Examples

https://github.com/facebook/ktfmt
https://github.com/Homebrew/homebrew-core/blob/352317b7b01c24a0d1cafe8080edf7bec4f36f98/Formula/k/ktfmt.rb#L20

packages:
  - type: github_release
    repo_owner: facebook
    repo_name: ktfmt
    description: A program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions
    asset: ktfmt-{{trimV .Version}}-with-dependencies.jar
    format: raw
$ ktfmt --help
ktfmt - command line Kotlin source code pretty-printer

Usage:
  ktfmt [OPTIONS] <File1.kt> <File2.kt> ...
  ktfmt @ARGFILE

ktfmt formats Kotlin source code files in-place, reporting for each file whether the
formatting succeeded or failed on standard error. If none of the style options are
passed, Meta's style is used.

Alternatively, ktfmt can read Kotlin source code from standard input and write the
formatted result on standard output.

Example:
     $ ktfmt --kotlinlang-style Main.kt src/Parser.kt
     Done formatting Main.kt
     Error formatting src/Parser.kt: @@@ERROR@@@; skipping.

Commands options:
  -h, --help                        Show this help message
  -v, --version                     Show version
  -n, --dry-run                     Don't write to files, only report files which
                                        would have changed
  --meta-style                      Use 2-space block indenting (default)
  --google-style                    Google internal style (2 spaces)
  --kotlinlang-style                Kotlin language guidelines style (4 spaces)
  --stdin-name=<name>               Name to report when formatting code from stdin
  --set-exit-if-changed             Sets exit code to 1 if any input file was not
                                        formatted/touched
  --do-not-remove-unused-imports    Leaves all imports in place, even if not used
  --enable-editorconfig             Enable .editorconfig overrides for supported formatting options (limited)
                                        see https://github.com/facebook/ktfmt/blob/main/README.md

ARGFILE:
  If the only argument begins with '@', the remainder of the argument is treated
  as the name of a file to read options and arguments from, one per line.

  e.g.
      $ cat arg-file.txt
      --google-style
      -n
      File1.kt
      File2.kt
      $ ktfmt @arg-file1.txt
      Done formatting File1.kt
      Done formatting File2.kt

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Mar 11, 2026
@suzuki-shunsuke suzuki-shunsuke added this to the v2.56.8 milestone Mar 11, 2026
@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds JAR file execution support by enabling dependency-injected path resolution. Introduces a lookPath field to the Controller struct and a new wrapExec function that detects .jar files and rewrites execution commands to use java -jar instead of direct execution.

Changes

Cohort / File(s) Summary
Controller Dependency Injection
pkg/controller/exec/controller.go
Adds lookPath field to Controller struct to support externalized executable path resolution, initialized to exec.LookPath.
JAR Wrapper Implementation
pkg/controller/exec/exec.go
Introduces wrapExec method and function to detect .jar file paths and transform invocations to java -jar <jar> <args>. Integrates wrapper into execution flow after installation/update and adds error handling for Java lookup failures.
JAR Wrapper Tests
pkg/controller/exec/exec_internal_test.go
Adds table-driven test covering three scenarios: non-jar executables, JAR files with arguments, and JAR files without arguments. Validates correct transformation and error propagation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A JAR in the garden needs Java to run,
So we wrap it up nicely—make it one!
With lookPath injected and wrapExec so bright,
Now aqua executes them just right! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description provides context via issue #4623 with examples, but lacks completion of the repository's required checklist template. Complete the required checklist from the description template, including confirmations about reading CONTRIBUTING.md, creating an issue beforehand, signed commits, and one-thing-per-PR principle.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: support executing .jar' directly and concisely describes the main change - adding support for executing JAR files by wrapping them with java -jar.
Linked Issues check ✅ Passed The changes implement the core requirement to wrap JAR execution through java -jar. The wrapExec function detects .jar files and rewrites invocations appropriately, directly addressing issue #4623's need for JAR file execution support.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing JAR execution support: adding the lookPath field for dependency injection, introducing wrapExec logic to detect and wrap JAR files, and testing the wrapper functionality. No unrelated changes are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-support-jar

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
unix.Exec's first argument must be an absolute path.
@suzuki-shunsuke

Copy link
Copy Markdown
Member Author

📝 ktfmt-0.61.jar doesn't work.

$ _JAVA_OPTIONS="-Duser.language=en -Duser.country=US" ~/go/bin/aqua exec -- ktfmt --help
Picked up _JAVA_OPTIONS: -Duser.language=en -Duser.country=US
Error: Unable to initialize main class com.facebook.ktfmt.cli.Main
Caused by: java.lang.NoClassDefFoundError: kotlin/NoWhenBranchMatchedException

ktfmt-0.61-with-dependencies.jar works.

@suzuki-shunsuke suzuki-shunsuke marked this pull request as ready for review March 11, 2026 14:41
@suzuki-shunsuke suzuki-shunsuke merged commit 899f96f into main Mar 11, 2026
21 of 22 checks passed
@suzuki-shunsuke suzuki-shunsuke deleted the feat-support-jar branch March 11, 2026 14:50
@github-project-automation github-project-automation Bot moved this to Done in main Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support built-in wrapper to execute tools like JAR

1 participant