fix: warn when --sources/--files are used with executable archives#2479
fix: warn when --sources/--files are used with executable archives#2479maxandersen wants to merge 1 commit into
Conversation
When running a JAR/WAR file with --sources or --files, these options were silently ignored. Now emits a warning and skips source/resource resolution for executable archives. Fixes #2363 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthrough
ChangesExecutable Archive Warning
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@quintesse wdyt ? going for warn about files /sources not being honored in this pr - mainly because I can't see a (good) usecase where we want to "reopen" the jar and add the resources....do you know of one or is this good enough |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/dev/jbang/cli/TestRun.java (1)
371-376: ⚡ Quick winConsider adding test coverage for
--fileswarning.The test correctly verifies the warning for
--sources, but there's no corresponding test for the--filesoption. Consider adding a similar test case to ensure both code paths are covered.📋 Suggested additional test
`@Test` void testJarWithFilesWarning() throws Exception { String jar = examplesTestFolder.resolve("hellojar.jar").toAbsolutePath().toString(); CaptureResult<Integer> result = checkedRun(null, "run", "--files", "SomeFile.txt", jar); assertThat(result.err, containsString("--files option is not supported for executable archives")); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/dev/jbang/cli/TestRun.java` around lines 371 - 376, Add a new JUnit test mirroring testJarWithSourcesWarning to cover the `--files` code path: create a method named testJarWithFilesWarning in the same TestRun class, build the jar path using examplesTestFolder.resolve("hellojar.jar").toAbsolutePath().toString(), call checkedRun(null, "run", "--files", "SomeFile.txt", jar) and assert that result.err contains the message "--files option is not supported for executable archives"; use the same CaptureResult<Integer> and assertion style as testJarWithSourcesWarning so both warnings are covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/test/java/dev/jbang/cli/TestRun.java`:
- Around line 371-376: Add a new JUnit test mirroring testJarWithSourcesWarning
to cover the `--files` code path: create a method named testJarWithFilesWarning
in the same TestRun class, build the jar path using
examplesTestFolder.resolve("hellojar.jar").toAbsolutePath().toString(), call
checkedRun(null, "run", "--files", "SomeFile.txt", jar) and assert that
result.err contains the message "--files option is not supported for executable
archives"; use the same CaptureResult<Integer> and assertion style as
testJarWithSourcesWarning so both warnings are covered.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 84086097-8f2f-410b-9e2d-bf706b47f1d8
📒 Files selected for processing (2)
src/main/java/dev/jbang/source/ProjectBuilder.javasrc/test/java/dev/jbang/cli/TestRun.java
Summary
--sourcesor--files, these options were silently ignored[WARN]message and skips source/resource resolution for executable archivesProjectBuilder.updateProject()so it fires before source file resolution (which would otherwise fail for nonexistent files)Fixes #2363
Test plan
testJarWithSourcesWarningtest inTestRun.javatestHelloWorldJarstill passesjbang run --sources Foo.java some.jarprints warning to stderr🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
--sourcesor--filesoptions with executable archives (jar/war files), as these options are not supported for this archive type.Tests