Skip to content

Fix --version command on CLI#316

Merged
tinder-maxwellelliott merged 3 commits intoTinder:masterfrom
sharmila-oai:sharmila/fix-version
Mar 10, 2026
Merged

Fix --version command on CLI#316
tinder-maxwellelliott merged 3 commits intoTinder:masterfrom
sharmila-oai:sharmila/fix-version

Conversation

@sharmila-oai
Copy link
Contributor

@sharmila-oai sharmila-oai commented Mar 4, 2026

Summary

Fix --version by generating the version file under a conventional resource path.

Root cause

VersionProvider reads the version from the classpath resource cli/version.

The generated version file was declared as:

outs = ["version"]

That caused the packaged jar to contain the generated file under a Bazel output path like:

bazel-out/.../cli/version

instead of cli/version, so --version could not find it.

This would result in an error like this when we attempt to run --version:

> java -jar bazel-bin/cli/bazel-diff_deploy.jar --version
java.lang.IllegalArgumentException: unknown version as version file not found in resources
	at com.bazel_diff.cli.VersionProvider.getVersion(VersionProvider.kt:13)
	at picocli.CommandLine$Model$CommandSpec.version(CommandLine.java:7032)
	at picocli.CommandLine.printVersionHelp(CommandLine.java:2749)
	at picocli.CommandLine.executeHelpRequest(CommandLine.java:1920)
	at picocli.CommandLine.executeHelpRequest(CommandLine.java:1909)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2176)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
	at picocli.CommandLine.execute(CommandLine.java:2078)
	at com.bazel_diff.Main$Companion.main(Main.kt:11)
	at com.bazel_diff.Main.main(Main.kt)

Fix

Generate the file at:

outs = ["src/main/resources/cli/version"]

rules_kotlin strips src/main/resources when packaging resources, so the deploy jar now contains:

cli/version

which matches the existing lookup in VersionProvider.

Verification

  • jar tf bazel-bin/cli/bazel-diff_deploy.jar now shows cli/version
  • java -jar bazel-bin/cli/bazel-diff_deploy.jar --version prints the expected version

@sharmila-oai sharmila-oai changed the title Fix version path Fix version resource packaging for --version Mar 4, 2026
@sharmila-oai sharmila-oai changed the title Fix version resource packaging for --version Fix --version command on CLI Mar 4, 2026
@sharmila-oai
Copy link
Contributor Author

Hey @tinder-maxwellelliott mind taking a look at this?

@tinder-maxwellelliott tinder-maxwellelliott merged commit 8b1869f into Tinder:master Mar 10, 2026
15 checks passed
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.

2 participants