This is an automated email from the ASF dual-hosted git repository. luigidemasi pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kit.git
commit ddcc1d905f9430c39562ed682923c14a103880ee Author: Luigi De Masi <[email protected]> AuthorDate: Thu Nov 26 09:24:35 2026 +0100 Fix #195: Report catalog compatibility from the configured runner Use live catalog evidence during target selection and keep the measured compatibility table with its tested runner in the MCP reference. Render the evidence example and Maven recovery command from distribution values. Distinguish target usage errors from incomplete evidence, identify malformed parent POMs, and share the checks for generated and existing applications. Co-authored-by: OpenAI Codex <[email protected]> --- CHANGELOG.md | 4 +-- distribution.properties | 3 ++ docs/commands.md | 2 +- docs/modules/ROOT/pages/commands.adoc | 4 +-- docs/modules/ROOT/pages/existing-project.adoc | 22 +++++++------- docs/modules/ROOT/pages/getting-started.adoc | 4 +-- docs/modules/ROOT/pages/mcp.adoc | 12 +++++--- docs/modules/ROOT/pages/migration.adoc | 4 +-- .../apache/camel/kit/command/TargetCommand.java | 22 +++++++------- .../camel/kit/config/DistributionConfig.java | 6 ++++ .../apache/camel/kit/config/TargetPomCheck.java | 24 +++++++++------ .../camel/kit/config/TargetRuntimeProfile.java | 4 +++ .../kit/generator/VersionPlaceholderResolver.java | 1 + .../org/apache/camel/kit/service/InitService.java | 19 ++++++------ .../camel-brainstorm/guides/version-selection.md | 35 ++++++++++++---------- .../main/resources/skills/camel-migrate/SKILL.md | 4 +-- .../src/main/resources/skills/shared/mcp-setup.md | 16 +++++----- .../camel/kit/command/TargetCommandTest.java | 27 ++++++++++++----- .../camel/kit/config/TargetRuntimeProfileTest.java | 8 +++-- .../kit/generator/ResourceConsistencyTest.java | 11 +++++++ .../apache/camel/kit/graph/ProjectDiscovery.java | 11 +++---- .../apache/camel/kit/graph/parser/PomParser.java | 16 ++++++++-- .../camel/kit/graph/parser/PomParserTest.java | 14 +++++++++ 23 files changed, 176 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d650e66a..ef437252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 verification. The new `target` command prints that profile, renders the application POM, and checks Maven and catalog evidence. Spring Boot templates import the application starter, Camel core and framework BOMs. Existing projects resolve inherited BOM properties per module and can recover a transitive core from Maven's dependency tree. - With the shipped MCP 4.22.1 runner, catalog-dependent design cannot complete for Spring Boot 4.18.4 or either - supported Quarkus row, including the default platform 3.33.3.2. These checks report INCOMPLETE (#195). + The workflow checks the configured runner before design approval. A core mismatch reports INCOMPLETE. + The MCP reference records the affected combinations for runner 4.22.1, including default Quarkus (#195). - Graph files now use format 1.1. CLI output such as `graph stats` reports namespaced types (for example `mule:flow`). Existing 1.0 graphs and legacy filters remain readable. diff --git a/distribution.properties b/distribution.properties index bd96f9c0..4b5832f8 100644 --- a/distribution.properties +++ b/distribution.properties @@ -49,6 +49,9 @@ quarkus.platform.4.14.7=3.27.3 spring.boot.4.22.1=4.1.1 spring.boot.4.18.4=3.5.16 +# Maven goal used to recover a BOM-only project's runtime dependency tree as JSON. +maven.dependency.plugin.version=3.8.1 + # ─── MCP Server Versions ─────────────────────────────────────────────────── camel.mcp.version=4.22.1 knowledge.mcp.group-id=io.github.luigidemasi diff --git a/docs/commands.md b/docs/commands.md index 3956012b..dc77d10b 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -268,7 +268,7 @@ For Pi, Camel-Kit generates `AGENTS.md`, project skills under `.pi/skills/`, pro selected in `target.*` in the workspace configuration. Use `--project-dir` to select the workspace. `--pom-template` prints the Maven template with runtime coordinates filled in. To check a generated application, supply `--check-effective-pom <xml>`, `--check-catalog <json>`, or both. For a transitive core -dependency, add `--dependency-tree <json>` from the same Maven module to the effective-POM check. Keep all evidence inside the workspace. Incomplete checks exit with status 1. The Camel JBang plugin exposes the same options under +dependency, add `--dependency-tree <json>` from the same Maven module to the effective-POM check. Keep all evidence inside the workspace. Incomplete checks exit with status 1. Invalid option combinations exit with status 2. The Camel JBang plugin exposes the same options under `camel kit target`. See [target selection](modules/ROOT/pages/migration.adoc#target-profile). ### camel-kit doctor diff --git a/docs/modules/ROOT/pages/commands.adoc b/docs/modules/ROOT/pages/commands.adoc index 27b23f9e..b48ee809 100644 --- a/docs/modules/ROOT/pages/commands.adoc +++ b/docs/modules/ROOT/pages/commands.adoc @@ -73,7 +73,7 @@ See xref:getting-started.adoc#existing-project[reinitializing existing projects] Configuration is read in three layers, the later overriding the earlier: the built-in `distribution.properties`, the user file given with `-c` or at its default path, and the `-p` flags. Any distribution property can be overridden; the common ones are `camel.main.version`, `camel.springboot.version`, `springboot.bom.version`, -`camel.quarkus.version`, `quarkus.platform.version`, `camel.mcp.version`, `knowledge.mcp.group-id`, `knowledge.mcp.version`, +`camel.quarkus.version`, `quarkus.platform.version`, `maven.dependency.plugin.version`, `camel.mcp.version`, `knowledge.mcp.group-id`, `knowledge.mcp.version`, `citrus.version` and `citrus.mcp.version`. The selected runtime and versions are persisted in `.camel-kit/config.properties`. @@ -90,7 +90,7 @@ coloured text elsewhere. === target Print the active runtime profile as JSON. Add `--migration` for the destination saved by -xref:migration.adoc#target-profile[the migration workflow]. An incomplete selection returns exit code 1. +xref:migration.adoc#target-profile[the migration workflow]. Incomplete selections or evidence return exit code 1. Incompatible options return usage error 2. ---- camel-kit target [--project-dir <path>] [--migration] [--pom-template] diff --git a/docs/modules/ROOT/pages/existing-project.adoc b/docs/modules/ROOT/pages/existing-project.adoc index fbdc639f..43182ad2 100644 --- a/docs/modules/ROOT/pages/existing-project.adoc +++ b/docs/modules/ROOT/pages/existing-project.adoc @@ -174,12 +174,15 @@ A starter or platform BOM can have a different version from Camel core. If init determine the core, it sets `project.needsResolvedCore=true`. Use the application's Maven settings and profiles. From the workspace root, run the following for each Camel application module, replacing `app/pom.xml` with its POM. For a vendor Spring Boot BOM, first set `project.catalogBom` to the published catalog provider -GAV from its starter release metadata. Use fresh output paths for each module. The dependency plugin supports JSON from version 3.7.0. +GAV from its starter release metadata. Use fresh output paths for each module. The tree goal requires a Maven +Dependency Plugin with JSON support. If the project uses an older plugin, use the fully qualified goal in the +installed `camel-brainstorm/guides/version-selection.md`. Init renders that goal from the distribution’s +`maven.dependency.plugin.version` setting. [source,shell] ---- ./mvnw -f app/pom.xml help:effective-pom -Doutput="$PWD/app/target/model.xml" -./mvnw -f app/pom.xml org.apache.maven.plugins:maven-dependency-plugin:3.8.1:tree -DoutputType=json -Dincludes=org.apache.camel:camel-core-engine -DoutputFile="$PWD/app/target/tree.json" +./mvnw -f app/pom.xml dependency:tree -DoutputType=json -Dincludes=org.apache.camel:camel-core-engine -DoutputFile="$PWD/app/target/tree.json" camel-kit target --check-effective-pom app/target/model.xml --dependency-tree app/target/tree.json ---- @@ -483,12 +486,9 @@ local run of one example. It is not a production certification, and its limits a [#catalog-limitation] === Runtime Catalog Version -Camel Kit starts the Camel MCP server at the version pinned by `camel.mcp.version` in `distribution.properties`, which -was 4.22.1 when this page was last checked (2026-11-17). With that runner, a Spring Boot or Quarkus catalog request for -a Camel version other than the server's own can be answered with the server's version, combining component metadata of -the requested target with newer EIP and model metadata -(link:https://issues.apache.org/jira/browse/CAMEL-26926[CAMEL-26926]). The recorded live run was not exposed to this, -because the application and the MCP server were both on 4.22.1. +The configured runner can return the requested starter or extension alongside its own Camel core catalog. +The xref:mcp.adoc#catalog-compatibility[compatibility table] identifies the runner and combinations tested. +In this recorded run the application and the runner used the same core version. When a catalog response reports a Camel version that differs from the one requested, or from the version recorded in `project.camelVersion`: @@ -498,10 +498,8 @@ When a catalog response reports a Camel version that differs from the one reques * Do not upgrade the application to match the MCP server. Camel Kit never changes the versions of an existing project, and a version upgrade belongs to `/camel-migrate`. -CAMEL-26926 is fixed in the Camel source, with the fix assigned to Camel 4.18.6, 4.22.3 and 4.24.0. That does not change -the runner Camel Kit installs, and it does not establish end-to-end acceptance for older-target Spring Boot or Quarkus -applications. Before relying on a fixed combination, confirm that the MCP artifact is published, that Camel Kit pins it, -and that a catalog request for your target version returns that version. +For background see link:https://issues.apache.org/jira/browse/CAMEL-26926[CAMEL-26926]. +Repeat the required catalog check after changing the runner or target. === Version 1 Scope diff --git a/docs/modules/ROOT/pages/getting-started.adoc b/docs/modules/ROOT/pages/getting-started.adoc index 6739c220..5a0c9e09 100644 --- a/docs/modules/ROOT/pages/getting-started.adoc +++ b/docs/modules/ROOT/pages/getting-started.adoc @@ -365,8 +365,8 @@ in Camel Kit. Three layers override them, the later winning: The workspace records the effective `camel.catalog.repos` used by the Camel MCP launcher. Configure any vendor repository in the Maven settings used for the destination build and in the catalog repository list at init. Keep repository credentials in Maven settings. -Before choosing a runtime, check the xref:mcp.adoc#binding[catalog compatibility table]. With the shipped -4.22.1 runner the default Quarkus target cannot complete a design requiring verified catalog artifacts. +Before choosing a runtime, consult the xref:mcp.adoc#catalog-compatibility[observed catalog results]. +Verify the selected target with your configured runner before approving a design that needs catalog artifacts. `camel-kit target` shows the selected application BOM, core version, repositories and catalog arguments. For a migration, `camel-kit target --migration` reads the separate destination selection. diff --git a/docs/modules/ROOT/pages/mcp.adoc b/docs/modules/ROOT/pages/mcp.adoc index c1072d56..fa391dd1 100644 --- a/docs/modules/ROOT/pages/mcp.adoc +++ b/docs/modules/ROOT/pages/mcp.adoc @@ -94,9 +94,12 @@ the catalog with documentation search; catalog tools (`camel_catalog_*`) remain The current defaults are Camel {camel-version} for Camel Main and Spring Boot, with Camel {camel-quarkus-version} on the Quarkus platform {quarkus-platform-version}; the catalog server artifact follows the Camel Main stream. -[[camel-tools]] -With the shipped Camel MCP 4.22.1 runner, required catalog checks have the following results for the -supported community targets. The runner can return the selected starter or extension alongside its bundled core. +[[catalog-compatibility]] +=== Catalog results for the tested runner + +These results were measured with Camel MCP 4.22.1 and the community targets listed below. The default +Quarkus platform in that distribution was 3.33.3.2. The runner can return the selected starter or extension +alongside its bundled core. [cols="1,1,1,2",options="header"] |=== @@ -104,7 +107,7 @@ supported community targets. The runner can return the selected starter or exten |Main |4.22.1 or 4.18.4 |Matches requested core |Pass |Spring Boot |4.22.1 |4.22.1 |Pass |Spring Boot |4.18.4 |4.22.1 |Incomplete -|Quarkus |4.18.3 |4.22.1 |Incomplete (default platform 3.33.3.2) +|Quarkus |4.18.3 |4.22.1 |Incomplete (platform 3.33.3.2) |Quarkus |4.14.7 |4.22.1 |Incomplete (platform 3.27.3) |=== @@ -113,6 +116,7 @@ cannot complete a design that requires verified catalog artifacts. The selected For a different runner or platform, verify the actual responses. See the xref:existing-project.adoc#catalog-limitation[runtime catalog limitation]. +[[camel-tools]] == The Camel catalog server The workflow allowlist covers the read-only and generation helpers the skills use; runtime mutation and control diff --git a/docs/modules/ROOT/pages/migration.adoc b/docs/modules/ROOT/pages/migration.adoc index 01cb0ecd..db8b3d46 100644 --- a/docs/modules/ROOT/pages/migration.adoc +++ b/docs/modules/ROOT/pages/migration.adoc @@ -62,8 +62,8 @@ target.springBootVersion=3.5.11 For Quarkus, set `target.applicationBom` to the full Camel platform BOM and `target.catalogVersion` to its managed `org.apache.camel.quarkus:camel-quarkus-catalog` version. The MCP lookup takes the platform BOM GAV. Main needs only `target.runtime=main` and the core version. -Check xref:mcp.adoc#binding[catalog availability] before selecting the destination. With the pinned runner, -the default Quarkus platform 3.33.3.2 cannot complete a design that requires verified component coordinates. +Consult the xref:mcp.adoc#catalog-compatibility[observed catalog results] when selecting the destination. +A design that needs verified components requires a successful check with the configured runner. Run `camel-kit target --migration` to inspect the profile. For a new Maven application, `camel-kit target --migration --pom-template` prints the POM with the selected imports and plugin version. diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/command/TargetCommand.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/command/TargetCommand.java index 1b241bf5..5be0a86a 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/command/TargetCommand.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/command/TargetCommand.java @@ -45,6 +45,12 @@ public class TargetCommand extends HelpAwareCommand { @Override public Integer call() { + if (dependencyTree != null && effectivePom == null) { + throw new UsageException("--dependency-tree requires --check-effective-pom"); + } + if ((catalogEvidence != null || effectivePom != null) && pomTemplate) { + throw new UsageException("Choose template output or target checks"); + } Path config = projectDir.resolve(".camel-kit/config.properties"); try { ConfinedPaths.requirePath(projectDir, config); @@ -55,29 +61,25 @@ public class TargetCommand extends HelpAwareCommand { throw new IOException( "Missing " + config + ". Run init here or use --project-dir for an initialized workspace."); } - if (dependencyTree != null && effectivePom == null) { - throw new IllegalArgumentException("--dependency-tree requires --check-effective-pom"); - } - if ((catalogEvidence != null || effectivePom != null) && pomTemplate) { - throw new IllegalArgumentException("Choose template output or target checks"); - } - boolean existing = !migration && "existing".equals(properties.getProperty("project.type")); + var application = !migration && "existing".equals(properties.getProperty("project.type")) + ? TargetPomCheck.Application.EXISTING : TargetPomCheck.Application.GENERATED; TargetPomCheck model = null; if (effectivePom != null) { model = new TargetPomCheck( read(effectivePom, 16 * 1024 * 1024), dependencyTree == null ? null : read(dependencyTree, 16 * 1024 * 1024)); - if (existing) { + if (application == TargetPomCheck.Application.EXISTING) { model.completeExistingProfile(properties); } - } else if (existing && "true".equals(properties.getProperty("project.needsResolvedCore")) + } else if (application == TargetPomCheck.Application.EXISTING + && "true".equals(properties.getProperty("project.needsResolvedCore")) && !properties.containsKey("project.camelVersion")) { throw new IOException( "Resolve project.camelVersion with --check-effective-pom and --dependency-tree for each Camel module"); } TargetRuntimeProfile profile = TargetRuntimeProfile.resolve(properties, migration); if (model != null) { - model.check(profile, existing); + model.check(profile, application); } if (catalogEvidence != null) { TargetCatalogEvidence.check(profile, read(catalogEvidence, 65536)); diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/DistributionConfig.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/DistributionConfig.java index 80a20be4..a05edca6 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/DistributionConfig.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/DistributionConfig.java @@ -40,6 +40,7 @@ public class DistributionConfig { private final String camelQuarkusSupported; private final String citrusVersion; private final String camelMcpVersion; + private final String mavenDependencyPluginVersion; private final String knowledgeMcpVersion; private final String knowledgeMcpGroupId; private final String citrusMcpVersion; @@ -66,6 +67,7 @@ public class DistributionConfig { this.camelSpringbootSupported = configured(props, bundled, "camel.springboot.supported"); this.camelQuarkusSupported = configured(props, bundled, "camel.quarkus.supported"); this.citrusVersion = configured(props, bundled, "citrus.version"); + this.mavenDependencyPluginVersion = configured(props, bundled, "maven.dependency.plugin.version"); this.camelMcpVersion = configured(props, bundled, "camel.mcp.version"); this.knowledgeMcpGroupId = configured(props, bundled, "knowledge.mcp.group-id"); this.knowledgeMcpVersion = configured(props, bundled, "knowledge.mcp.version"); @@ -350,6 +352,10 @@ public class DistributionConfig { return citrusVersion; } + public String mavenDependencyPluginVersion() { + return mavenDependencyPluginVersion; + } + public String camelMcpVersion() { return camelMcpVersion; } diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetPomCheck.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetPomCheck.java index cf6c4bff..a7ef61c8 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetPomCheck.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetPomCheck.java @@ -18,6 +18,16 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; /** Checks Maven's effective dependency management without executing the generated project. */ public final class TargetPomCheck { + public enum Application { + GENERATED, + EXISTING; + + // A generated POM must supply every declaration. Existing projects may obtain them elsewhere. + private boolean requires(Object declaration) { + return this == GENERATED || declaration != null; + } + } + private final Model model; private final Map<String, String> managed = new HashMap<>(); private final String treeCore; @@ -62,16 +72,16 @@ public final class TargetPomCheck { } } - public void check(TargetRuntimeProfile target, boolean existing) throws IOException { + public void check(TargetRuntimeProfile target, Application application) throws IOException { if (target.applicationBom() == null) { throw new IOException("Expected a Maven destination with an application BOM"); } if (treeCore != null) { requireVersion("resolved org.apache.camel:camel-core-engine", target.camelVersion(), treeCore); } - if (!existing || treeCore == null) { + if (application == Application.GENERATED || treeCore == null) { String core = managed.get("org.apache.camel:camel-core-engine:jar"); - if (existing && core == null) { + if (application == Application.EXISTING && core == null) { throw new IOException("Camel core is transitive. Supply --dependency-tree from the same Maven module"); } requireVersion("org.apache.camel:camel-core-engine", target.camelVersion(), core); @@ -93,7 +103,7 @@ public final class TargetPomCheck { managed.get("org.apache.camel.quarkus:camel-quarkus-catalog:jar")); } var configured = model.getBuild() == null ? null : model.getBuild().getPluginsAsMap().get(plugin); - if (!existing || configured != null) { + if (application.requires(configured)) { requireVersion(plugin, pluginVersion, configured == null ? null : configured.getVersion()); } for (Dependency dep : model.getDependencies()) { @@ -101,17 +111,13 @@ public final class TargetPomCheck { || "org.apache.camel.quarkus".equals(dep.getGroupId()) || "org.springframework.boot".equals(dep.getGroupId())) { String version = managed.get(dep.getManagementKey()); - if (!existing || version != null) { + if (application.requires(version)) { requireVersion(dep.getManagementKey(), version, dep.getVersion()); } } } } - public static void check(TargetRuntimeProfile target, byte[] effectivePom) throws IOException { - new TargetPomCheck(effectivePom, null).check(target, false); - } - private static String resolvedCore(Model model, byte[] tree) throws IOException { JsonNode root = new ObjectMapper().enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION) .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS).readTree(tree); diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetRuntimeProfile.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetRuntimeProfile.java index eb9df651..a1405721 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetRuntimeProfile.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/config/TargetRuntimeProfile.java @@ -75,6 +75,10 @@ public record TargetRuntimeProfile( List<String> repositories = Arrays.stream(repos.split(",", -1)).map(String::strip).toList(); // Profiles are copied into design and verification reports. Credentials belong in Maven settings. for (String repository : repositories) { + if (repository.isEmpty()) { + throw new IllegalArgumentException( + "Empty repository in camel.catalog.repos. Supply a URL for each comma-separated entry"); + } String url = repository.replaceFirst("^[A-Za-z0-9_.-]+=", ""); try { URI uri = new URI(url); diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/generator/VersionPlaceholderResolver.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/generator/VersionPlaceholderResolver.java index 8c300991..f11815e5 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/generator/VersionPlaceholderResolver.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/generator/VersionPlaceholderResolver.java @@ -51,6 +51,7 @@ class VersionPlaceholderResolver { static Map<String, String> buildVersionTemplateData(DistributionConfig dist) { Map<String, String> data = new java.util.LinkedHashMap<>(); data.put("CAMEL_VERSION", dist.camelMainVersion()); + data.put("MAVEN_DEPENDENCY_PLUGIN_VERSION", dist.mavenDependencyPluginVersion()); data.put("CAMEL_MAIN_VERSION", dist.camelMainVersion()); data.put("CAMEL_SPRINGBOOT_VERSION", dist.camelSpringbootVersion()); data.put("CAMEL_QUARKUS_VERSION", dist.camelQuarkusVersion()); diff --git a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/service/InitService.java b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/service/InitService.java index bb69c818..ce72a53e 100644 --- a/kit/camel-kit-core/src/main/java/org/apache/camel/kit/service/InitService.java +++ b/kit/camel-kit-core/src/main/java/org/apache/camel/kit/service/InitService.java @@ -38,6 +38,8 @@ import org.apache.camel.kit.generator.QuteTemplateEngine; import org.apache.camel.kit.graph.GraphBuildResult; import org.apache.camel.kit.graph.GraphSerializer; import org.apache.camel.kit.graph.ParserDiagnostic; +import org.apache.camel.kit.graph.ProjectDiscovery; +import org.apache.camel.kit.graph.ProjectDiscovery.DiscoveryResult; import org.apache.camel.kit.graph.ProjectGraph; import org.apache.camel.kit.graph.RuntimeDetector; import org.apache.camel.kit.graph.model.NodeType; @@ -561,9 +563,7 @@ public class InitService { ProjectGraph graph = result.graph(); DistributionConfig distribution = request.distribution(); - // Use ProjectDiscovery for comprehensive metadata - org.apache.camel.kit.graph.ProjectDiscovery.DiscoveryResult discovery - = org.apache.camel.kit.graph.ProjectDiscovery.discover(graph); + DiscoveryResult discovery = ProjectDiscovery.discover(graph); boolean isExistingProject = "existing".equals(config.getProperty("project.type")); String runtime = discovery.runtime(); @@ -590,7 +590,7 @@ public class InitService { // With conflicting evidence neither value is locked; the gap below tells the user what to resolve. if (discovery.platformBomVersion() != null) { - String applicationBom = org.apache.camel.kit.graph.ProjectDiscovery.applicationBom(graph, runtime); + String applicationBom = ProjectDiscovery.applicationBom(graph, runtime); if (applicationBom != null) { config.setProperty("project.applicationBom", applicationBom); } @@ -601,6 +601,7 @@ public class InitService { config.setProperty("project.springBootVersion", discovery.springBootVersion()); } + // A POM edit can change the resolved dependency tree even when the imported platform stays the same. String inputs = mavenInputs(projectRoot, result); config.setProperty("project.mavenInputs", inputs); boolean sameModel = inputs.equals(previous.getProperty("project.mavenInputs")) @@ -663,7 +664,7 @@ public class InitService { // Gaps the graph could not fill (e.g. routes defined in unsupported layouts): workflow must inspect source List<String> gaps = new ArrayList<>(discovery.coverageGaps()); if (discovery.camelVersion() == null && config.containsKey("project.camelVersion")) { - gaps.remove(org.apache.camel.kit.graph.ProjectDiscovery.UNRESOLVED_PLATFORM_CORE); + gaps.remove(ProjectDiscovery.UNRESOLVED_PLATFORM_CORE); } if (!gaps.isEmpty()) { config.setProperty("project.discoveryGaps", String.join(" | ", gaps)); @@ -693,19 +694,18 @@ public class InitService { config.setProperty("project.configFilesCount", String.valueOf(discovery.configFilesCount())); } - // Flag unsupported versions - if (config.getProperty("project.camelVersion", "").startsWith("3.")) { + String camelVersion = config.getProperty("project.camelVersion"); + if (DiscoveryResult.isUnsupportedVersion(camelVersion)) { config.setProperty("project.unsupportedVersion", "true"); config.setProperty("project.unsupportedReason", "Camel 3.x is not supported. Please upgrade to Camel 4.x."); reportWarning(request, warnings, - "Camel " + config.getProperty("project.camelVersion") + "Camel " + camelVersion + " is not supported. Please upgrade to Camel 4.x " + "before adding features."); } // forage.version must track project.camelVersion - String camelVersion = config.getProperty("project.camelVersion"); if (camelVersion != null) { String forageVersion = distribution.forageVersionForCamel(camelVersion); if (forageVersion != null) { @@ -719,6 +719,7 @@ public class InitService { writeVersionConfig(config, distribution, runtime); } + // Catalog coordinates belong to the selected platform and repositories, independently of other POM edits. if (runtime != null && config.getProperty("project.camelVersion") != null && config.getProperty("project.platformBomVersion") != null && List.of("project.type", "project.runtime", "project.camelVersion", "project.applicationBom", diff --git a/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/version-selection.md b/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/version-selection.md index 348c8592..308c05aa 100644 --- a/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/version-selection.md +++ b/kit/camel-kit-core/src/main/resources/skills/camel-brainstorm/guides/version-selection.md @@ -43,18 +43,23 @@ if project.type == "existing": ### Recover the core version from Maven -When init found the runtime and application BOM but no declared core version, use the project's wrapper and -usual Maven settings/profiles. For each affected Camel leaf module run `help:effective-pom -Doutput=<absolute-model-file>` -and `org.apache.maven.plugins:maven-dependency-plugin:3.8.1:tree -DoutputType=json -Dincludes=org.apache.camel:camel-core-engine -DoutputFile=<absolute-tree-file>` -with `-f <leaf-pom>`. Use dependency plugin 3.7.0 or later for JSON. Write fresh, separate outputs inside the workspace. -Run `{COMMAND_PREFIX} target --check-effective-pom <model> --dependency-tree <tree>` with the workspace-relative paths. -For a vendor Spring Boot BOM, first record the published provider GAV in `project.catalogBom` from the selected -release metadata. The read-only check prints the resolved profile. If all affected modules agree, record its `camelVersion` as -`project.camelVersion` in `.camel-kit/config.properties`. Also record the verified `project.springBootVersion` -or `project.catalogVersion` for that runtime. Leave `target.*` intact. A conflicting module, failed Maven run or incomplete target check -leaves the selection unresolved. Stop and report which module needs attention. For Camel 3.x use the migration workflow. -Recheck after a change to the POMs, effective profiles, repositories or settings. On reinitialization, Kit keeps the -recovered core for unchanged POMs and catalog selections for an unchanged platform. +If init found the runtime and application BOM but no declared Camel core version: + +1. Use the project's Maven wrapper, settings and profiles. For each affected Camel leaf module, run these goals + with `-f <leaf-pom>`. Write fresh outputs to separate files inside the workspace. + - `help:effective-pom -Doutput=<absolute-model-file>` + - `org.apache.maven.plugins:maven-dependency-plugin:{MAVEN_DEPENDENCY_PLUGIN_VERSION}:tree -DoutputType=json -Dincludes=org.apache.camel:camel-core-engine -DoutputFile=<absolute-tree-file>` +2. For a vendor Spring Boot BOM, record the catalog provider GAV from its release metadata in + `project.catalogBom` in `.camel-kit/config.properties`. +3. Run `{COMMAND_PREFIX} target --check-effective-pom <model> --dependency-tree <tree>` for each module with + its workspace-relative paths. The command prints the verified profile. If Maven fails, a check is incomplete + or the modules disagree, stop and identify the affected module. +4. When all modules agree, record `camelVersion` as `project.camelVersion` in `.camel-kit/config.properties`. + For Spring Boot, record `springBootVersion` as `project.springBootVersion`. For Quarkus, record + `runtimeCatalogVersion` as `project.catalogVersion`. Leave `target.*` intact. For Camel 3.x use the migration workflow. + +Repeat the checks after a change to POMs, effective profiles, repositories or settings. Re-init keeps the +recovered core for unchanged Maven inputs and catalog coordinates for an unchanged platform. For a required catalog check, use Rule 3 in `shared/mcp-setup.md`. When needed, record `project.catalogVersion` from the imported Quarkus platform's dependency management, or @@ -70,10 +75,8 @@ version is Camel 3.x. ## Step 1: Select Runtime Platform (Greenfield Projects Only) -Before selecting a runtime, explain the required catalog check for the installed runner. With the shipped -4.22.1 runner, Spring Boot 4.18.4 and both listed Quarkus targets (including the default 4.18.3) return -core 4.22.1. Designs requiring catalog verification on these rows remain incomplete. Preserve the user's -selected target and show this limitation before requesting design approval. +Explain that catalog availability depends on the configured runner and the selected target. Once the user +selects a target, run Rule 3 in `shared/mcp-setup.md` and report its result before design approval. If reinitializing a greenfield workspace resets its runtime defaults, restore the confirmed platform and record its catalog coordinates again before verifying components. diff --git a/kit/camel-kit-core/src/main/resources/skills/camel-migrate/SKILL.md b/kit/camel-kit-core/src/main/resources/skills/camel-migrate/SKILL.md index a0f5699e..1730e015 100644 --- a/kit/camel-kit-core/src/main/resources/skills/camel-migrate/SKILL.md +++ b/kit/camel-kit-core/src/main/resources/skills/camel-migrate/SKILL.md @@ -357,8 +357,8 @@ required. If any Java, Blueprint, plugin, or code-generation work must remain an selection or dispatch design work; require the user to choose Spring Boot or Quarkus. **Select the migration target** (all modes). Load `shared/mcp-setup.md`, Rules 1 and 3. -Disclose any known catalog mismatch before the user chooses a target. With the pinned 4.22.1 runner, -the default Quarkus platform 3.33.3.2 cannot supply verified catalog evidence for its Camel 4.18.3 core. Use the installed runtime +After selecting a destination, verify its catalog with the configured runner. Report the Rule 3 result before +design approval or, in direct mode, before using catalog-derived artifacts. Use the installed runtime matrix in `camel-brainstorm/guides/version-selection.md` for community choices. Source module POMs, graph evidence, and `project.*` are observations. If modules disagree, show the conflicting modules and ask which destination applies. An explicit common destination resolves the question. Never select a downstream build from a source suffix. diff --git a/kit/camel-kit-core/src/main/resources/skills/shared/mcp-setup.md b/kit/camel-kit-core/src/main/resources/skills/shared/mcp-setup.md index 910655cf..7d5f3cea 100644 --- a/kit/camel-kit-core/src/main/resources/skills/shared/mcp-setup.md +++ b/kit/camel-kit-core/src/main/resources/skills/shared/mcp-setup.md @@ -168,18 +168,18 @@ The version binding comes from `.camel-kit/config.properties`. For a required ch ```json { "profile": { - "runtime": "main", "camelVersion": "4.22.1", "applicationBom": null, "springBootVersion": null, - "repositories": ["https://repo.maven.apache.org/maven2/"], "runtimeCatalogVersion": "4.22.1", - "catalog": {"runtime":"main","camelVersion":"4.22.1","platformBom":"org.apache.camel:camel-catalog:4.22.1"} + "runtime": "main", "camelVersion": "{CAMEL_MAIN_VERSION}", "applicationBom": null, "springBootVersion": null, + "repositories": ["https://repo.maven.apache.org/maven2/"], "runtimeCatalogVersion": "{CAMEL_MAIN_VERSION}", + "catalog": {"runtime":"main","camelVersion":"{CAMEL_MAIN_VERSION}","platformBom":"org.apache.camel:camel-catalog:{CAMEL_MAIN_VERSION}"} }, "list": { "name": "camel_catalog_components", - "arguments": {"runtime":"main","camelVersion":"4.22.1","platformBom":"org.apache.camel:camel-catalog:4.22.1","filter":"timer","label":"","limit":2}, + "arguments": {"runtime":"main","camelVersion":"{CAMEL_MAIN_VERSION}","platformBom":"org.apache.camel:camel-catalog:{CAMEL_MAIN_VERSION}","filter":"timer","label":"","limit":2}, "result": {"content":[{"type":"text","text":"<original list response text>"}]} }, "maven": { "name": "camel_catalog_component_maven", - "arguments": {"runtime":"main","camelVersion":"4.22.1","platformBom":"org.apache.camel:camel-catalog:4.22.1","component":"timer"}, + "arguments": {"runtime":"main","camelVersion":"{CAMEL_MAIN_VERSION}","platformBom":"org.apache.camel:camel-catalog:{CAMEL_MAIN_VERSION}","component":"timer"}, "result": {"content":[{"type":"text","text":"<original Maven response text>"}]} } } @@ -192,9 +192,9 @@ The version binding comes from `.camel-kit/config.properties`. For a required ch changed profile or version mismatch makes the required check **INCOMPLETE**. Leave dependent lookups unverified. Repeat after any profile change. -With the shipped 4.22.1 runner the supported Spring Boot 4.18.4 and Quarkus 4.18.3/4.14.7 rows return -core 4.22.1. This includes the default Quarkus platform 3.33.3.2. Inform the user before selecting these rows: -design assembly requires verified artifacts and cannot complete while that mismatch persists. +A runner can return its bundled Camel core for a different requested target. Before design approval, +report the actual Rule 3 result for the configured runner. If the returned catalog core differs from the +requested core, report both versions and mark the check INCOMPLETE. Design assembly requires verified catalog artifacts. Detail tools do not all return `camelVersion`. Do not require or invent a field that is absent from a tool's schema. Validate each returned artifact identity and each consumed field against the requested type and name, bound to the diff --git a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/command/TargetCommandTest.java b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/command/TargetCommandTest.java index 7d0dbe2d..b02ab26b 100644 --- a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/command/TargetCommandTest.java +++ b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/command/TargetCommandTest.java @@ -10,7 +10,6 @@ import java.util.List; import org.apache.camel.kit.CamelKitMain; import org.apache.camel.kit.output.SystemPrinter; -import org.apache.camel.kit.util.TemplateUtils; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -28,7 +27,10 @@ class TargetCommandTest { private String run(int status, String... options) { var args = new ArrayList<>(List.of("target", "--project-dir", dir.toString())); args.addAll(List.of(options)); - String[] argv = args.toArray(String[]::new); + return execute(status, args.toArray(String[]::new)); + } + + private String execute(int status, String... argv) { var output = new StringWriter(); var main = new CamelKitMain(new SystemPrinter()); try { @@ -48,19 +50,26 @@ class TargetCommandTest { @Test void mainAcceptsEvidenceInTheDocumentedShape() throws Exception { - config("project.runtime=main\nproject.camelVersion=4.22.1\ncamel.catalog.repos=https://repo.maven.apache.org/maven2/\n"); - String guide = TemplateUtils.readTemplate("skills/shared/mcp-setup.md"); + execute(0, "init", dir.toString(), "--ai", "claude", "--no-fetch", + "-p", "camel.main.version=4.99.1", "-p", "camel.mcp.version=4.99.2", + "-p", "maven.dependency.plugin.version=3.99.1", + "-p", "camel.catalog.repos=https://repo.maven.apache.org/maven2/"); + assertTrue(Files.readString(dir.resolve(".mcp.json")).contains("camel-jbang-mcp:4.99.2")); + Path skills = dir.resolve(".claude/skills"); + assertTrue(Files.readString(skills.resolve("camel-brainstorm/guides/version-selection.md")) + .contains("maven-dependency-plugin:3.99.1:tree")); + String guide = Files.readString(skills.resolve("shared/mcp-setup.md")); String example = guide.substring(guide.indexOf("### Rule 3:")); int start = example.indexOf("```json") + 7; ObjectNode wire = (ObjectNode) JSON.readTree(example.substring(start, example.indexOf("```", start))); assertEquals(JSON.readTree(run(0)), wire.get("profile")); ((ObjectNode) wire.at("/list/result/content/0")).put("text", """ - {"camelVersion":"4.22.1","components":[{"name":"timer"}],"count":1} + {"camelVersion":"4.99.1","components":[{"name":"timer"}],"count":1} """); ((ObjectNode) wire.at("/maven/result/content/0")).put("text", """ - {"name":"timer","groupId":"org.apache.camel","artifactId":"camel-timer","version":"4.22.1"} + {"name":"timer","groupId":"org.apache.camel","artifactId":"camel-timer","version":"4.99.1"} """); Path file = dir.resolve("evidence.json"); JSON.writeValue(file.toFile(), wire); @@ -73,9 +82,11 @@ class TargetCommandTest { @Test void reportsMissingWorkspaceAndRejectsConflictingOrOversizedInputs() throws Exception { assertTrue(run(1).contains("Run init")); + String conflict = run(2, "--pom-template", "--check-catalog", "data"); + assertTrue(conflict.contains("Choose template")); + assertFalse(conflict.contains("INCOMPLETE")); + assertTrue(run(2, "--dependency-tree", "tree").contains("requires --check-effective-pom")); config("project.runtime=main\nproject.camelVersion=4.22.1\n"); - assertTrue(run(1, "--pom-template", "--check-catalog", "data").contains("Choose template")); - assertTrue(run(1, "--dependency-tree", "tree").contains("requires --check-effective-pom")); try (var data = new RandomAccessFile(dir.resolve("data").toFile(), "rw")) { data.setLength(65537); assertTrue(run(1, "--check-catalog", "data").contains("65536")); diff --git a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/config/TargetRuntimeProfileTest.java b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/config/TargetRuntimeProfileTest.java index 6b0bdcad..fc7d3578 100644 --- a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/config/TargetRuntimeProfileTest.java +++ b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/config/TargetRuntimeProfileTest.java @@ -66,7 +66,7 @@ class TargetRuntimeProfileTest { var model = new DefaultModelBuilderFactory().newInstance().build(request).getEffectiveModel(); var bytes = new ByteArrayOutputStream(); new MavenXpp3Writer().write(bytes, model); - TargetPomCheck.check(profile, bytes.toByteArray()); + new TargetPomCheck(bytes.toByteArray(), null).check(profile, TargetPomCheck.Application.GENERATED); for (Dependency dep : model.getDependencies()) { assertEquals(FixtureBoms.MANAGED.get(dep.getGroupId() + ":" + dep.getArtifactId()), dep.getVersion(), dep::getManagementKey); @@ -74,7 +74,8 @@ class TargetRuntimeProfileTest { model.getDependencies().get(0).setVersion("0.1"); var wrong = new ByteArrayOutputStream(); new MavenXpp3Writer().write(wrong, model); - assertThrows(IOException.class, () -> TargetPomCheck.check(profile, wrong.toByteArray())); + assertThrows(IOException.class, () -> new TargetPomCheck(wrong.toByteArray(), null).check(profile, + TargetPomCheck.Application.GENERATED)); } } @@ -86,6 +87,9 @@ class TargetRuntimeProfileTest { config.setProperty("camel.catalog.repos", "https://user:[email protected]/releases"); var invalid = assertThrows(IllegalArgumentException.class, () -> TargetRuntimeProfile.resolve(config, true)); assertFalse(invalid.getMessage().contains("secret")); + config.setProperty("camel.catalog.repos", "https://example.org/releases, "); + assertTrue(assertThrows(IllegalArgumentException.class, () -> TargetRuntimeProfile.resolve(config, true)) + .getMessage().contains("Empty repository")); config.remove("camel.catalog.repos"); config.remove("target.catalogBom"); assertThrows(IllegalArgumentException.class, () -> TargetRuntimeProfile.resolve(config, true)); diff --git a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/ResourceConsistencyTest.java b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/ResourceConsistencyTest.java index 29d0f4d7..e4dbe997 100644 --- a/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/ResourceConsistencyTest.java +++ b/kit/camel-kit-core/src/test/java/org/apache/camel/kit/generator/ResourceConsistencyTest.java @@ -168,6 +168,17 @@ class ResourceConsistencyTest { @TempDir Path tempDir; + @Test + void catalogGuidesUseDistributionVersionsOrObservedResults() throws IOException { + Path skills = repositoryRoot().resolve("kit/camel-kit-core/src/main/resources/skills"); + Pattern literalVersion = Pattern.compile("\\b\\d+\\.\\d+\\.\\d+\\b"); + for (String file : List.of("shared/mcp-setup.md", "camel-migrate/SKILL.md", + "camel-brainstorm/guides/version-selection.md")) { + String instructions = Files.readString(skills.resolve(file)).replaceFirst("(?s)\\A---\\R.*?\\R---\\R", ""); + assertFalse(literalVersion.matcher(instructions).find(), file); + } + } + @Test void retiredCommandScanAllowsGuidePaths() { Pattern retiredCommand = STALE_PATTERNS.stream() diff --git a/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/ProjectDiscovery.java b/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/ProjectDiscovery.java index 3e7c566d..44e1af02 100644 --- a/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/ProjectDiscovery.java +++ b/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/ProjectDiscovery.java @@ -436,11 +436,12 @@ public final class ProjectDiscovery { Map<String, Set<String>> versionEvidence) { public boolean isUnsupportedVersion() { - if (camelVersion == null) { - return false; - } - // Camel 3.x is unsupported - return camelVersion.startsWith("3."); + return isUnsupportedVersion(camelVersion); + } + + /** Applies the same support policy to source-discovered and Maven-resolved versions. */ + public static boolean isUnsupportedVersion(String version) { + return version != null && version.startsWith("3."); } /** True when more than one runtime or more than one Camel version was found: nothing may be locked. */ diff --git a/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/parser/PomParser.java b/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/parser/PomParser.java index 921ca5da..774708d8 100644 --- a/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/parser/PomParser.java +++ b/kit/camel-kit-graph/src/main/java/org/apache/camel/kit/graph/parser/PomParser.java @@ -41,13 +41,22 @@ public class PomParser implements GraphParser { GraphParser.requireSafeFiles(projectRoot, files); Map<Path, Model> models = new LinkedHashMap<>(); for (Path file : files) { + Model model; try (Reader input = new StringReader(new String(GraphParser.readSource(file), StandardCharsets.UTF_8))) { - models.put(file.normalize(), new MavenXpp3Reader().read(input)); + model = new MavenXpp3Reader().read(input); } catch (Exception e) { throw new IllegalArgumentException("Failed to parse POM: " + file, e); } + var parent = model.getParent(); + if (parent != null && (parent.getGroupId() == null || parent.getArtifactId() == null + || parent.getVersion() == null)) { + throw new IllegalArgumentException( + "Failed to parse POM: " + file + + " (Maven parent requires groupId, artifactId and version)"); + } + models.put(file.normalize(), model); } - models.forEach((file, model) -> parsePom(file, projectRoot, graph, model, inheritedProperties(file, models))); + models.forEach((file, model) -> parsePom(file, projectRoot, graph, model, models)); } // Follow only matching parents already included in the workspace scan. Siblings do not share properties. @@ -84,8 +93,9 @@ public class PomParser implements GraphParser { return properties; } - private void parsePom(Path pomFile, Path projectRoot, ProjectGraph graph, Model model, Properties properties) { + private void parsePom(Path pomFile, Path projectRoot, ProjectGraph graph, Model model, Map<Path, Model> models) { try { + Properties properties = inheritedProperties(pomFile, models); String groupId = model.getGroupId() != null ? model.getGroupId() : (model.getParent() != null ? model.getParent().getGroupId() : "unknown"); diff --git a/kit/camel-kit-graph/src/test/java/org/apache/camel/kit/graph/parser/PomParserTest.java b/kit/camel-kit-graph/src/test/java/org/apache/camel/kit/graph/parser/PomParserTest.java index 172255cc..36ac89d3 100644 --- a/kit/camel-kit-graph/src/test/java/org/apache/camel/kit/graph/parser/PomParserTest.java +++ b/kit/camel-kit-graph/src/test/java/org/apache/camel/kit/graph/parser/PomParserTest.java @@ -24,6 +24,20 @@ class PomParserTest { new PomParser().parse(TEST_PROJECT, graph); } + @Test + void malformedParentReportsTheDeclaringPom(@TempDir Path root) throws Exception { + Files.writeString(root.resolve("pom.xml"), + "<project><modelVersion>4.0.0</modelVersion><groupId>example</groupId>" + + "<artifactId>root</artifactId><version>1</version></project>"); + Path child = Files.createDirectory(root.resolve("child")).resolve("pom.xml"); + Files.writeString(child, + "<project><modelVersion>4.0.0</modelVersion><parent><groupId>example</groupId>" + + "<artifactId>root</artifactId></parent><artifactId>child</artifactId></project>"); + var failure = assertThrows(IllegalArgumentException.class, () -> new PomParser().parse(root, graph)); + assertTrue(failure.getMessage().contains(child.toString())); + assertTrue(failure.getMessage().contains("parent requires groupId, artifactId and version")); + } + @Test void parsesProjectArtifact() { assertTrue(graph.hasNode("maven:com.example:order-service"));
