You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/03/13 08:38:31 UTC
[PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
gnodet opened a new pull request, #21978:
URL: https://github.com/apache/camel/pull/21978
## Summary
- Adds a `camel wrapper` command that installs wrapper scripts (`camelw` / `camelw.cmd`) and a `.camel/camel-wrapper.properties` file for pinning a specific Camel version to a project directory
- The wrapper scripts download the `camel-launcher` JAR on first use and run it, similar to how Maven Wrapper (`mvnw`) works
- Supports `--camel-version` to specify the version (defaults to current) and `--repo-url` to specify a custom Maven repository
## Test plan
- [x] Unit tests for `WrapperCommand` covering file creation, properties content, default version, custom repo URL, and script content
- [ ] Manual testing: run `camel wrapper` and verify `camelw` / `camelw.cmd` / `.camel/camel-wrapper.properties` are created
- [ ] Manual testing: run `./camelw version get` to verify the wrapper downloads and runs the launcher
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #21978:
URL: https://github.com/apache/camel/pull/21978#discussion_r2931179978
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/WrapperCommand.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.Set;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.util.IOHelper;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+
+@Command(name = "wrapper", description = "Install Camel wrapper scripts for version pinning", sortOptions = false,
+ showDefaultValues = true)
+public class WrapperCommand extends CamelCommand {
+
+ private static final String DEFAULT_REPO_URL = "https://repo1.maven.org/maven2";
+ private static final String WRAPPER_PROPERTIES_FILE = "camel-wrapper.properties";
+ private static final String CAMEL_DIR = ".camel";
+
+ @CommandLine.Option(names = { "--camel-version" },
+ description = "Camel version to pin (defaults to current version)")
+ String camelVersion;
+
+ @CommandLine.Option(names = { "--repo-url" },
+ description = "Maven repository URL for downloading the launcher",
+ defaultValue = DEFAULT_REPO_URL)
+ String repoUrl = DEFAULT_REPO_URL;
+
+ @CommandLine.Option(names = { "--dir", "--directory" },
+ description = "Directory where wrapper files will be created",
+ defaultValue = ".")
+ String directory = ".";
+
+ public WrapperCommand(CamelJBangMain main) {
+ super(main);
+ }
+
+ @Override
+ public Integer doCall() throws Exception {
+ if (camelVersion == null || camelVersion.isEmpty()) {
+ CamelCatalog catalog = new DefaultCamelCatalog();
+ camelVersion = catalog.getCatalogVersion();
+ }
+
+ Path baseDir = Paths.get(directory).toAbsolutePath().normalize();
+ Path camelDir = baseDir.resolve(CAMEL_DIR);
+
+ // Create .camel directory
+ Files.createDirectories(camelDir);
+
+ // Write camel-wrapper.properties
+ writeProperties(camelDir);
+
+ // Write camelw script
+ writeScript(baseDir, "camelw");
+
+ // Write camelw.cmd script
+ writeScript(baseDir, "camelw.cmd");
+
+ printer().println("Apache Camel wrapper installed successfully.");
+ printer().println(" Camel version: " + camelVersion);
+ printer().println(" Properties: " + camelDir.resolve(WRAPPER_PROPERTIES_FILE));
+ printer().println(" Unix script: " + baseDir.resolve("camelw"));
+ printer().println(" Windows script: " + baseDir.resolve("camelw.cmd"));
+ printer().println();
+ printer().println("You can now use ./camelw instead of camel to run with the pinned version.");
+
+ return 0;
+ }
+
+ void writeProperties(Path camelDir) throws IOException {
+ String distributionUrl = buildDistributionUrl();
+ String content = String.join(System.lineSeparator(),
+ "# Licensed to the Apache Software Foundation (ASF) under one",
Review Comment:
Already addressed — the current code uses text blocks (see `writeProperties` method at line 94).
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/WrapperCommandTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.dsl.jbang.core.common.PathUtils;
+import org.apache.camel.dsl.jbang.core.common.StringPrinter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class WrapperCommandTest {
Review Comment:
These tests are very fast (< 1 second total) — they just write files to a temp directory with no network calls or container startup. Keeping them as separate methods gives better test isolation and clearer failure messages when something breaks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #21978:
URL: https://github.com/apache/camel/pull/21978#issuecomment-4054040218
Tests are lightweight (file I/O only, no Camel context startup), each executing in milliseconds (~1.2s total for all 7 tests). Separate methods are preferred to test each aspect independently, but happy to consolidate if you feel strongly about it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #21978:
URL: https://github.com/apache/camel/pull/21978
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #21978:
URL: https://github.com/apache/camel/pull/21978#discussion_r2930140369
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/WrapperCommand.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.Set;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.util.IOHelper;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+
+@Command(name = "wrapper", description = "Install Camel wrapper scripts for version pinning", sortOptions = false,
+ showDefaultValues = true)
+public class WrapperCommand extends CamelCommand {
+
+ private static final String DEFAULT_REPO_URL = "https://repo1.maven.org/maven2";
+ private static final String WRAPPER_PROPERTIES_FILE = "camel-wrapper.properties";
+ private static final String CAMEL_DIR = ".camel";
+
+ @CommandLine.Option(names = { "--camel-version" },
+ description = "Camel version to pin (defaults to current version)")
+ String camelVersion;
+
+ @CommandLine.Option(names = { "--repo-url" },
+ description = "Maven repository URL for downloading the launcher",
+ defaultValue = DEFAULT_REPO_URL)
+ String repoUrl = DEFAULT_REPO_URL;
+
+ @CommandLine.Option(names = { "--dir", "--directory" },
+ description = "Directory where wrapper files will be created",
+ defaultValue = ".")
+ String directory = ".";
+
+ public WrapperCommand(CamelJBangMain main) {
+ super(main);
+ }
+
+ @Override
+ public Integer doCall() throws Exception {
+ if (camelVersion == null || camelVersion.isEmpty()) {
+ CamelCatalog catalog = new DefaultCamelCatalog();
+ camelVersion = catalog.getCatalogVersion();
+ }
+
+ Path baseDir = Paths.get(directory).toAbsolutePath().normalize();
+ Path camelDir = baseDir.resolve(CAMEL_DIR);
+
+ // Create .camel directory
+ Files.createDirectories(camelDir);
+
+ // Write camel-wrapper.properties
+ writeProperties(camelDir);
+
+ // Write camelw script
+ writeScript(baseDir, "camelw");
+
+ // Write camelw.cmd script
+ writeScript(baseDir, "camelw.cmd");
+
+ printer().println("Apache Camel wrapper installed successfully.");
+ printer().println(" Camel version: " + camelVersion);
+ printer().println(" Properties: " + camelDir.resolve(WRAPPER_PROPERTIES_FILE));
+ printer().println(" Unix script: " + baseDir.resolve("camelw"));
+ printer().println(" Windows script: " + baseDir.resolve("camelw.cmd"));
+ printer().println();
+ printer().println("You can now use ./camelw instead of camel to run with the pinned version.");
+
+ return 0;
+ }
+
+ void writeProperties(Path camelDir) throws IOException {
+ String distributionUrl = buildDistributionUrl();
+ String content = String.join(System.lineSeparator(),
+ "# Licensed to the Apache Software Foundation (ASF) under one",
Review Comment:
What about using multiline strings (text block)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21978:
URL: https://github.com/apache/camel/pull/21978#issuecomment-4053596556
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: 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](https://camel.apache.org/community/team/#committers) have access to the summary.
:warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on code in PR #21978:
URL: https://github.com/apache/camel/pull/21978#discussion_r2930146092
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/WrapperCommandTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.dsl.jbang.core.common.PathUtils;
+import org.apache.camel.dsl.jbang.core.common.StringPrinter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class WrapperCommandTest {
Review Comment:
How much time does this test need to be executed? would it be possible in case it needs much time to condense the Tests method in only one method?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23150: Add camel wrapper command for version pinning [camel]
Posted by "Croway (via GitHub)" <gi...@apache.org>.
Croway commented on PR #21978:
URL: https://github.com/apache/camel/pull/21978#issuecomment-4054190627
> Tests are lightweight (file I/O only, no Camel context startup), each executing in milliseconds (~1.2s total for all 7 tests). Separate methods are preferred to test each aspect independently, but happy to consolidate if you feel strongly about it.
nono, that is great, thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org