Skip to content

CAMEL-22544: jbang dependency update supports multi-file and --scan-routes#22208

Open
gnodet wants to merge 6 commits intomainfrom
calm-hisser
Open

CAMEL-22544: jbang dependency update supports multi-file and --scan-routes#22208
gnodet wants to merge 6 commits intomainfrom
calm-hisser

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Mar 23, 2026

JIRA: CAMEL-22544

Summary

  • Enhanced camel dependency update command to accept multiple target files (pom.xml or Java source files with //DEPS)
  • Added --scan-routes flag to sync dependencies from route definitions:
    • Manages only org.apache.camel dependencies
    • Preserves non-Camel dependencies (e.g., guava, netty)
    • Removes unused Camel dependencies no longer needed by routes
    • Idempotent on re-execution (no duplicates)
  • Route definition files (YAML, XML) passed as arguments are automatically classified and used as source files for the export pipeline
  • In scan-routes mode, existing Camel //DEPS in Java target files are stripped before running the export pipeline, so only actual route-based dependencies are resolved
  • Added input validation preventing mixed pom.xml and Java source files as update targets
  • Fixed PrepareCamelJBangCommandsMojo regex to match this (not just main) as constructor arg, fixing stale metadata generation
  • Fixed docs gulp race condition: added strict: false to gulp.src glob options so ENOENT errors during directory traversal (when test temp dirs are cleaned up concurrently) are warnings instead of failures
  • Regenerated all jbang command metadata and docs

Test plan

  • Existing DependencyUpdateTest (Maven pom.xml with quarkus, spring-boot, main runtimes) passes
  • Scan-routes Maven tests use fixture files from src/test/resources/dependency-update/ (no Init+Export at runtime):
    • --scan-routes adds new deps from routes (Maven, all runtimes)
    • --scan-routes removes unused Camel deps from pom.xml
    • --scan-routes adds and removes deps simultaneously
  • JBang //DEPS tests (inline fixtures):
    • Multi-file JBang //DEPS update
    • --scan-routes preserves non-Camel //DEPS in JBang files
    • --scan-routes is idempotent on re-execution

@github-actions github-actions bot added the dsl label Mar 23, 2026
@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 build-all, build-dependents, 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 marked this pull request as draft March 23, 2026 21:20
@gnodet gnodet marked this pull request as ready for review March 23, 2026 21:29
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

🧪 CI tested the following changed modules:

  • docs
  • dsl/camel-jbang/camel-jbang-core
  • tooling/maven/camel-package-maven-plugin

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.

Build reactor — dependencies compiled but only changed modules were tested (6 modules)
  • Camel :: Docs
  • Camel :: Docs [pom]
  • Camel :: JBang :: Core
  • Camel :: JBang :: Core [jar]
  • Camel :: Maven Plugins :: Camel Maven Package
  • Camel :: Maven Plugins :: Camel Maven Package [maven-plugin]

gnodet and others added 3 commits March 31, 2026 09:02
…outes

- Accept multiple target files (pom.xml or Java source files with //DEPS)
- Add --scan-routes flag to sync dependencies from route definitions:
  - Manages only org.apache.camel dependencies
  - Preserves non-Camel dependencies
  - Removes unused Camel dependencies
  - Idempotent on re-execution
- Route files (YAML, XML) passed as arguments are used as source files
  for the export pipeline dependency resolution
- In scan-routes mode, Camel //DEPS in Java target files are stripped
  before export to prevent stale deps from being resolved

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Merge DependencyUpdateJBangTest into DependencyUpdateTest (single test class)
- Use fixture files from src/test/resources for scan-routes Maven tests
  instead of calling Init+Export at runtime
- Add input validation preventing mixed pom.xml and Java targets
- Guard addMavenDeps against targetLineNumber == -1
- Clean up blank lines left by removeMavenDeps
- Clarify isCamelDependency javadoc on group prefix matching
- Fix PrepareCamelJBangCommandsMojo regex to match 'this' (not just 'main')
  as constructor arg, fixing stale metadata generation
- Regenerate all jbang command metadata and docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet and others added 2 commits March 31, 2026 09:35
Add strict: false to gulp.src glob options so that ENOENT errors
during directory traversal are warnings rather than failures. This
prevents race conditions when the docs gulp build runs in parallel
with tests that create and delete temporary directories.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use system temp directory instead of target/ for test working dirs
and exclude .camel-jbang directories from gulpfile source glob
pattern to avoid race condition with docs gulp build.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@apupier
Copy link
Copy Markdown
Contributor

apupier commented Apr 2, 2026

What's the status? is it ready for another round of review? If yes, you should re-request review from claudio4j so that he is aware (and others too)

@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented Apr 2, 2026

Claude Code on behalf of Guillaume Nodet

@claudio4j Both review comments have been addressed in the latest push:

  1. Fixture files instead of jbang init/export — The scan-routes Maven tests now use pre-built fixture files from src/test/resources/dependency-update/ (pom.xml per runtime + route YAML), avoiding jbang invocations in CI.
  2. Single test class — Merged all tests from DependencyUpdateJBangTest into DependencyUpdateTest. Single test class now covers all scenarios.

Ready for another look when you get a chance.

@gnodet gnodet requested a review from claudio4j April 2, 2026 15:46
# Conflicts:
#	docs/gulpfile.js
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-bind.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-cmd-receive.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-debug.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-dependency-copy.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-dependency-list.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-dependency-update.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-explain.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-export.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-harden.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-run.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-sbom.adoc
#	docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-transform-route.adoc
#	dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
#	tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelJBangCommandsMojo.java
@davsclaus
Copy link
Copy Markdown
Contributor

Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: docs/user-manual/modules/ROOT/pages/jbang-commands/camel-jbang-dependency-update.adoc
modified: dsl/camel-jbang/camel-jbang-core/src/generated/resources/META-INF/camel-jbang-commands-metadata.json
modified: tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelJBangCommandsMojo.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants