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 4edcf09fe1caa2565453b40b354bee679bcb35ab Author: Ankit Garg <[email protected]> AuthorDate: Tue Nov 3 14:51:33 2026 +0530 fix #147: keep the project version token through skill installation Use {project.camelVersion} in run-script.md so VersionPlaceholderResolver leaves it alone, and make the regression test assert on the executable run.sh block and the installed guide instead of the whole file. Co-authored-by: Claude Sonnet 5.5 <[email protected]> --- .../skills/camel-implement/guides/run-script.md | 6 ++--- .../kit/generator/ResourceConsistencyTest.java | 31 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/kit/camel-kit-core/src/main/resources/skills/camel-implement/guides/run-script.md b/kit/camel-kit-core/src/main/resources/skills/camel-implement/guides/run-script.md index 33a688d9..62386b58 100644 --- a/kit/camel-kit-core/src/main/resources/skills/camel-implement/guides/run-script.md +++ b/kit/camel-kit-core/src/main/resources/skills/camel-implement/guides/run-script.md @@ -13,7 +13,7 @@ DataMapper file). | Rule | Detail | |------|--------| | JBang alias | Use `jbang camel@apache/camel run` -- **NOT** `org.apache.camel:camel-jbang:VERSION:runner` (non-existent Maven artifact) and **NOT** bare `camel run` (requires global install) | -| Camel version | Pass `--camel-version={CAMEL_VERSION}` so the script runs the version the project was designed against. Without it the alias runs the Camel version its own script defaults to, which can differ from `project.camelVersion` | +| Camel version | Pass `--camel-version={project.camelVersion}` so the script runs the version the project was designed against. Without it the alias runs the Camel version its own script defaults to, which can differ from `project.camelVersion` | | Route files | List every file in `ROUTE_FILES` in the single `camel run` command | | XSL files | List every file in `XSL_FILES` in the same command; omit XSL arguments only when the list is empty | | Properties | Pass via `--properties=application.properties` | @@ -42,11 +42,11 @@ echo "Starting {MODULE_NAME} integration..." jbang camel@apache/camel run \ {route-file-1}.camel.yaml {route-file-N}.camel.yaml \ {xslt-file-1}.xsl {xslt-file-N}.xsl \ - --camel-version={CAMEL_VERSION} \ + --camel-version={project.camelVersion} \ --properties=application.properties ``` -Replace `{CAMEL_VERSION}` with the literal version read from `.camel-kit/config.properties` (for example `4.22.1`), never +Replace `{project.camelVersion}` with the literal `CAMEL_VERSION` read from `.camel-kit/config.properties`, never with a placeholder or a stripped minor version. Expand `ROUTE_FILES` and `XSL_FILES` completely and remove the illustrative `-1`/`-N` placeholders. Never reduce the 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 9611e709..d0227995 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 @@ -1285,12 +1285,41 @@ class ResourceConsistencyTest { String orchestrator = Files.readString(root.resolve("camel-implement/guides/orchestrator.md")); String greenfield = Files.readString(root.resolve("camel-plan/guides/task-template-greenfield.md")); - assertTrue(runScript.contains("--camel-version={CAMEL_VERSION}")); + String pin = "--camel-version={project.camelVersion}"; assertTrue(runScript.contains("`project.camelVersion`")); + assertTrue(runScriptCommand(runScript).contains(pin), "run.sh template must pin the project version"); + + // Installation resolves {UPPER_CASE} tokens to the distribution defaults; the project-context token must + // survive it even when the distribution version differs from the project version. + Path installed = tempDir.resolve("run-script-installed.md"); + Files.writeString(installed, runScript); + new VersionPlaceholderResolver().substitute(installed, DistributionConfig.loadFromClasspathOrDefaults(), + "camel kit"); + String installedGuide = Files.readString(installed); + assertTrue(installedGuide.contains(pin), "installed guide must keep the project-context token"); + assertTrue(runScriptCommand(installedGuide).contains(pin), "installed run.sh template must keep the pin"); + assertFalse(installedGuide.contains("--camel-version=" + + DistributionConfig.loadFromClasspathOrDefaults().camelMainVersion())); + + // Removing the flag from the executable block must fail even though the rules table still mentions it. + String withoutFlag = runScript.replace(" " + pin + " \\\n", ""); + assertNotEquals(runScript, withoutFlag); + assertFalse(runScriptCommand(withoutFlag).contains(pin)); assertTrue(orchestrator.contains("`MODULE_DIR`, `CAMEL_VERSION`, `ROUTE_FILES`")); assertTrue(greenfield.contains("--camel-version=[CAMEL_VERSION]")); } + /** Returns the fenced bash block that holds the executable {@code jbang camel@apache/camel run} command. */ + private static String runScriptCommand(String guide) { + Matcher block = Pattern.compile("```bash\\n(.*?)```", Pattern.DOTALL).matcher(guide); + while (block.find()) { + if (block.group(1).contains("jbang camel@apache/camel run")) { + return block.group(1); + } + } + return fail("run.sh bash block not found"); + } + @Test void migrationContractsPreserveRuntimeAndCanonicalTransformationEngine() throws IOException { Path root = repositoryRoot().resolve("kit/camel-kit-core/src/main/resources/skills");
