Skip to content

Sharing JBang installation #2580

Open
sinhasebur wants to merge 1 commit into
jbangdev:mainfrom
sinhasebur:main
Open

Sharing JBang installation #2580
sinhasebur wants to merge 1 commit into
jbangdev:mainfrom
sinhasebur:main

Conversation

@sinhasebur

Copy link
Copy Markdown
Contributor

Summary

cli/App.java contained a TODO noting duplicated JBang installation discovery logic in Wrapper.java.

This PR introduces a shared JBangInstallation helper that:

  • locates the current JBang installation
  • supports flat and .jbang wrapper layouts
  • handles .jar, .bin, and .bin.exe artifacts
  • validates the required scripts and JAR
  • provides separate script and JAR directories

App and Wrapper now use this helper while retaining their command-specific copy behavior.

Testing

./gradlew test --tests "dev.jbang.cli.TestApp"
./gradlew test
./gradlew spotlessCheck
./gradlew build

All tests and formatting checks pass.

Copilot AI review requested due to automatic review settings July 3, 2026 17:29
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0b5437a0-7f1c-4e4b-80d3-20312a96b4d4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR factors out duplicated “where is my running JBang installation located?” logic from App and Wrapper into a shared JBangInstallation helper, so both commands resolve scripts/JAR directories consistently across flat and .jbang wrapper layouts.

Changes:

  • Added JBangInstallation helper to locate/validate the running installation’s scripts and JAR directories.
  • Updated Wrapper and App to use JBangInstallation instead of duplicating path/layout checks.
  • Added initial unit tests for flat vs wrapper layout discovery.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/main/java/dev/jbang/cli/JBangInstallation.java New helper to locate scripts + JAR directories relative to the running artifact.
src/main/java/dev/jbang/cli/Wrapper.java Wrapper install now uses JBangInstallation to find source dirs for copying.
src/main/java/dev/jbang/cli/App.java Offline install path now uses JBangInstallation and can copy scripts/JAR from separate dirs.
src/test/java/dev/jbang/cli/TestJBangInstallation.java New tests for installation discovery behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/dev/jbang/cli/App.java Outdated
Comment thread src/test/java/dev/jbang/cli/TestJBangInstallation.java
@sinhasebur sinhasebur changed the title Sharing JBang installation to avoid duplicate code Sharing JBang installation Jul 3, 2026
@maxandersen

Copy link
Copy Markdown
Collaborator

this is probably fine but I literally just updated this code so this would need a rebase.

Updated to include changes from the main branch.
@sinhasebur

Copy link
Copy Markdown
Contributor Author

Thanks, i have rebased and updated the code to account for the changes.

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.

3 participants