Skip to content

CAMEL-23973: camel export - Add --parent-pom option#24906

Merged
davsclaus merged 3 commits into
mainfrom
fix/CAMEL-23973
Jul 19, 2026
Merged

CAMEL-23973: camel export - Add --parent-pom option#24906
davsclaus merged 3 commits into
mainfrom
fix/CAMEL-23973

Conversation

@davsclaus

@davsclaus davsclaus commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds --parent-pom=groupId:artifactId:version option to camel export for setting a custom Maven parent POM in the exported project
  • Supports all three runtimes: Spring Boot, Quarkus, and Camel Main
  • For Spring Boot, replaces the default spring-boot-starter-parent; the spring-boot-dependencies BOM in <dependencyManagement> keeps version management intact
  • Also configurable via camel.jbang.parentPom in application.properties
  • Adds MavenGav.parseStrictGav() for shared strict GAV validation — used by both --gav and --parent-pom validation across all export commands
  • Validates --parent-pom early in export() with a friendly error message (consistent with --gav validation)
  • Includes documentation in the export guide

Test plan

  • Unit tests: shouldExportWithParentPom — verifies custom parent is set for all runtimes, and Spring Boot BOM is preserved
  • Unit tests: shouldExportWithoutParentPom — verifies default behavior is unchanged
  • All 81 existing ExportTest tests pass
  • Full reactor build passes with regenerated metadata

Claude Code on behalf of davsclaus

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

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-23973 — camel export --parent-pom option

Overall: Well-implemented feature that addresses a real organizational need for custom parent POMs in exported Camel projects.

What works well

  1. Thoughtful Spring Boot BOM handling — When --parent-pom replaces the default spring-boot-starter-parent, the spring-boot-dependencies BOM remains in <dependencyManagement> so version management continues to work. The FreeMarker templates use [#if ParentGroupId??] conditionals cleanly.

  2. Clean layering with enrichParentPom() — Centralizing the model population in ExportBaseCommand and calling it uniformly from all three runtime exporters avoids duplication. Each exporter adds one line (enrichParentPom(model)) and the templates handle the rest.

  3. Comprehensive coverage — All six POM templates updated, tests for both with/without parent POM across all runtimes, documentation in the export guide with examples, and application.properties support via camel.jbang.parentPom.

  4. <relativePath/> in generated parent block — Prevents Maven from searching parent directories, which is the right default for a remote parent.

Non-blocking observation

Input validation for malformed --parent-pom — The enrichParentPom() method splits on : and silently ignores input with != 3 parts. If a user specifies --parent-pom=com.ourorg:camel-parent (forgetting the version), the export succeeds with exit 0 but the parent POM is never applied. For Spring Boot, this silently falls back to the default spring-boot-starter-parent.

The existing --gav option validates and fails fast:

if (ids.length != 3) {
    printer().printErr("--gav must be in syntax: groupId:artifactId:version");
    return 1;
}

Consider adding similar validation for --parent-pom for consistency:

protected void enrichParentPom(Map<String, Object> model) {
    if (parentPom != null) {
        String[] parts = parentPom.split(":");
        if (parts.length != 3) {
            throw new IllegalArgumentException(
                "--parent-pom must be in syntax: groupId:artifactId:version, got: " + parentPom);
        }
        model.put("ParentGroupId", parts[0]);
        model.put("ParentArtifactId", parts[1]);
        model.put("ParentVersion", parts[2]);
    }
}

This can be addressed as a follow-up — the feature works correctly for valid input.


Claude Code on behalf of gnodet — AI-generated review

…parseStrictGav

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 @gnodet! Good catch on the silent ignore for malformed --parent-pom.

Addressed by adding MavenGav.parseStrictGav(String) — a shared strict GAV validation method that requires exactly groupId:artifactId:version and throws IllegalArgumentException otherwise. Updated all four call sites:

  • ExportSpringBoot, ExportCamelMain, ExportQuarkus--gav validation now uses parseStrictGav instead of inline split+check
  • ExportBaseCommand.enrichParentPom()--parent-pom now uses parseStrictGav and fails fast on malformed input instead of silently ignoring

Also regenerated camel-jbang-configuration-metadata.json.

Claude Code on behalf of davsclaus

@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 after 2nd commit (36f357c): Strict GAV validation via MavenGav.parseStrictGav() — nice 👍

The new commit addresses the observation from my earlier review about silently ignoring malformed --parent-pom values. Changes:

  1. New MavenGav.parseStrictGav() — validates exactly 3 colon-separated parts, throws IllegalArgumentException with a descriptive message otherwise. Good Javadoc.
  2. enrichParentPom() — now uses parseStrictGav() instead of manual split(":"), so malformed input throws rather than being silently ignored.
  3. Bonus: unified --gav validationExportCamelMain, ExportQuarkus, and ExportSpringBoot all upgraded to use parseStrictGav() for --gav as well, replacing the manual ids.length != 3 checks. Consistent.

Minor note: enrichParentPom() lets the IllegalArgumentException propagate uncaught, whereas the --gav validation wraps it in a try/catch with a clean error message. If a user passes --parent-pom foo:bar they'll get a stack trace rather than a friendly message. Not blocking — it's strictly better than silently ignoring, and easily refined later if needed.

My earlier approval stands.

Claude Code on behalf of gnodet — AI-generated review

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • docs
  • dsl/camel-jbang/camel-jbang-core
  • tooling/camel-tooling-maven

🔬 Scalpel shadow comparison — Scalpel: 12 tested, 24 compile-only — current: 9 all tested

Maveniverse Scalpel detected 36 affected modules (current approach: 9).

⚠️ 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 24 (generated code, meta-modules)

Modules Scalpel would test (12)
  • camel-catalog
  • camel-jbang-core
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-tooling-maven
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • docs
Modules with tests skipped (24)
  • 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-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

ℹ️ 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

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. 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 (36 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 :: Tooling :: Maven
  • 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 19, 2026
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.

Re-review (3rd commit 816a4a11): Early --parent-pom validation with friendly error message.

Good addition — validates --parent-pom early (right after --gav validation) using parseStrictGav() with a user-friendly error message, consistent across all three export commands (CamelMain, Quarkus, SpringBoot). This catches malformed parent POM coordinates before any export work begins, matching the existing --gav validation pattern directly above.

Prior approval stands. ✅

Claude Code on behalf of gnodet — AI-generated review

@davsclaus davsclaus self-assigned this Jul 19, 2026
@davsclaus davsclaus added the enhancement New feature or request label Jul 19, 2026
@davsclaus
davsclaus merged commit 195ce6b into main Jul 19, 2026
6 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-23973 branch July 19, 2026 18:44
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.

2 participants