Skip to content

CAMEL-24226: camel run/export - add --resource-dirs option - #24986

Merged
davsclaus merged 6 commits into
mainfrom
feature/CAMEL-24226-resource-dirs
Jul 22, 2026
Merged

CAMEL-24226: camel run/export - add --resource-dirs option#24986
davsclaus merged 6 commits into
mainfrom
feature/CAMEL-24226-resource-dirs

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

Summary

  • Add --resource-dirs option to camel run, camel export, and camel kubernetes run/export commands
  • Recursively copies specified directories into src/main/resources preserving the full directory structure
  • For camel run, adds files to classpath with their directory-relative paths preserved
  • For camel export, copies files into src/main/resources/<dir>/... preserving structure
  • For paths with .. (e.g., ../shared/schemas), uses only the last directory name as target (schemas/)
  • Rejects absolute paths for safety
  • Limits to 1000 files per directory to prevent accidental full filesystem traversal
  • Multiple directories supported via comma separation or repeated option

Example:

camel export --resource-dirs=soap,wsdl

With soap/schemas/common.xsd produces src/main/resources/soap/schemas/common.xsd.

Test plan

  • New ResourceDirsTest with 9 tests covering: validation, recursive walking, max file limit, .. path mapping, deep subdirectory structure
  • All 854 existing camel-jbang-core tests pass
  • All 128 existing camel-jbang-plugin-kubernetes tests pass

Claude Code on behalf of davsclaus

…rectories preserving structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet 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.

Review: CAMEL-24226 — camel run/export --resource-dirs option

Well-crafted feature with clean code, thorough documentation (all command reference pages updated), and good test coverage (9 tests). The security safeguards — absolute path rejection, 1000-file limit, try-with-resources on Files.walk — are solid.

Findings

1. copyResourceDirs edge case with bare --resource-dirs=..

When the user passes --resource-dirs=.., Path.of("..").getFileName() returns "..", so target = srcResourcesDir.resolve(baseName) resolves to src/main/resources/..src/main/, writing files one level above the intended target. This isn't a security vulnerability (CLI user is trusted and has filesystem access), but it's a correctness issue — files silently end up in the wrong location.

A guard in validateResourceDir rejecting paths whose getFileName() is ".." would close it:

if (path.getFileName() != null && path.getFileName().toString().equals("..")) {
    throw new IllegalArgumentException(
            "--resource-dirs path must end with a named directory, not '..': " + dir);
}

The existing test nestedParentPathShouldMapToLastComponent covers ../../mydata/foo (named last component ✅) but not the bare .. case.

2. Missing upgrade guide entry

New CLI option — per project convention, a brief mention in camel-4x-upgrade-guide-4_22.adoc would help discoverability.

Neither blocks the merge — the edge case requires a user to specifically pass .. as the sole resource dir, and the upgrade guide is a convention item.


Reviewed with Claude Code on behalf of gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Added the guard in validateResourceDir to reject bare .. paths, plus a test for it (b168843).

The upgrade guide entry — I'll skip for now as this is a new option (not a change to existing behavior).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
davsclaus and others added 2 commits July 21, 2026 19:07
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@github-actions github-actions Bot removed the catalog label Jul 21, 2026

@gnodet gnodet 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.

Re-review: CAMEL-24226 — camel run/export --resource-dirs option

Re-reviewing after the latest commit. The bare .. edge case I flagged has been properly addressed:

if (path.getFileName() != null && path.getFileName().toString().equals("..")) {
    throw new IllegalArgumentException(
            "--resource-dirs path must end with a named directory, not '..': " + dir);
}

And the validateShouldRejectBareDotDot test covers it. Good fix. ✅

The code is clean — validation, recursive walking, Kubernetes integration all look correct. Documentation is thorough.

CI note

CI is currently failing with "Fail if there are uncommitted changes" — generated files need to be regenerated and committed.

Still open (non-blocking)

Upgrade guide entry for the new CLI option (camel-4x-upgrade-guide-4_22.adoc).

Will approve once CI is green.


Reviewed with Claude Code on behalf of gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>

@gnodet gnodet 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.

Claude Code on behalf of gnodet

✅ LGTM — CI fix applied, promoting to approve

Re-reviewing after the new commit chore: regen jbang configuration metadata for resourceDirs option which addresses the CI failure I flagged in my previous review (uncommitted generated files).

Java source code — unchanged from my previous review. The validateResourceDir() bare .. rejection and the rest of the implementation remain sound.

Generated files — jbang configuration metadata now properly committed, which should resolve the CI "uncommitted changes" check.

Documentation — good coverage in both camel-jbang-running.adoc and camel-jbang-projects.adoc with examples.

My earlier suggestion about an upgrade guide entry for the new --resource-dirs option still stands — it helps users discover new features when upgrading — but it's not blocking.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • docs
  • dsl/camel-jbang/camel-jbang-core
  • dsl/camel-jbang/camel-jbang-plugin-kubernetes

🔬 Scalpel shadow comparison — Scalpel: 12 tested, 23 compile-only — current: 8 all tested

Maveniverse Scalpel detected 35 affected modules (current approach: 8).

⚠️ Modules only in Scalpel (27)
  • apache-camel
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs

Skip-tests mode would test 12 modules (4 direct + 8 downstream), skip tests for 23 (generated code, meta-modules)

Modules Scalpel would test (12)
  • camel-catalog
  • camel-jbang-core
  • camel-jbang-mcp
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • docs
Modules with tests skipped (23)
  • apache-camel
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 1 test(s) disabled on GitHub Actions
  • dsl/camel-jbang/camel-jbang-plugin-kubernetes: 8 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core, dsl/camel-jbang/camel-jbang-plugin-kubernetes. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (35 modules)
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.22.0 milestone Jul 22, 2026
@davsclaus davsclaus self-assigned this Jul 22, 2026
@davsclaus davsclaus added the enhancement New feature or request label Jul 22, 2026
@davsclaus
davsclaus merged commit eaf2f35 into main Jul 22, 2026
6 checks passed
@davsclaus
davsclaus deleted the feature/CAMEL-24226-resource-dirs branch July 22, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants