Skip to content

fix: select default init template by extension - #2637

Open
arnabnandy7 wants to merge 1 commit into
jbangdev:mainfrom
arnabnandy7:fix/kotlin-init-template
Open

fix: select default init template by extension#2637
arnabnandy7 wants to merge 1 commit into
jbangdev:mainfrom
arnabnandy7:fix/kotlin-init-template

Conversation

@arnabnandy7

Copy link
Copy Markdown
Contributor

Summary

Fixes #2635.

When jbang init is used without an explicit template, JBang now selects an available hello.<extension> template matching the requested file extension.

For example:

jbang init hello.kt

now uses the built-in hello.kt template instead of selecting the Java hello template and failing with:

Template expects java extension, not kt

The existing Java template remains the fallback for .java and extensionless filenames. Explicit template selection and extension validation remain unchanged.

Changes

  • Select the default initialization template based on the requested extension.
  • Add regression tests for Kotlin and Groovy initialization.
  • Document extension-based default template selection.
  • Document Kotlin script creation using jbang init hello.kt.

Verification

./gradlew test --tests "dev.jbang.cli.TestInit"

@coderabbitai

coderabbitai Bot commented Aug 7, 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: 52d36db6-a7de-41b3-89fa-a6a734739792

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.

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

Copy link
Copy Markdown

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: a533550cbb

ℹ️ 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 src/main/java/dev/jbang/cli/Init.java
@arnabnandy7
arnabnandy7 force-pushed the fix/kotlin-init-template branch from a533550 to 50f1c05 Compare August 7, 2026 18:49
Signed-off-by: Arnab Nandy <arnab_nandy7@yahoo.com>
@arnabnandy7
arnabnandy7 force-pushed the fix/kotlin-init-template branch from 50f1c05 to 6daed77 Compare August 8, 2026 04:22
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.

Template expects java extension, not kt

1 participant