This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new ecbaad896c9d CAMEL-26933: camel-launcher - camel.bat ships with CRLF
line endings, and accepts an early-access JDK (#29915)
ecbaad896c9d is described below
commit ecbaad896c9d4d4c8000cd3b21ebe46b319d5842
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 14 11:37:57 2026 +0100
CAMEL-26933: camel-launcher - camel.bat ships with CRLF line endings, and
accepts an early-access JDK (#29915)
launcher-content.xml gives camel.bat a file set of its own with dos line
endings (and camel.sh unix), so the ZIP, WinGet ZIP and tarball ship camel.bat
with CRLF whatever the checkout has. camel.bat splits the Java version on '.',
'-' and '+', so an early-access JDK such as 26-ea is read as 26, as camel.sh
does. LauncherArchiveLayoutIT checks the line endings of both scripts.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../src/main/assembly/launcher-content.xml | 10 ++++++++++
.../src/main/resources/bin/camel.bat | 5 +++--
.../dsl/jbang/launcher/CamelBatDiscoveryTest.java | 20 +++++++++++++++++++-
.../jbang/launcher/LauncherArchiveLayoutIT.java | 22 ++++++++++++++++++++++
4 files changed, 54 insertions(+), 3 deletions(-)
diff --git
a/dsl/camel-jbang/camel-launcher/src/main/assembly/launcher-content.xml
b/dsl/camel-jbang/camel-launcher/src/main/assembly/launcher-content.xml
index 5ce9d9eb5b16..5bf6575a558f 100644
--- a/dsl/camel-jbang/camel-launcher/src/main/assembly/launcher-content.xml
+++ b/dsl/camel-jbang/camel-launcher/src/main/assembly/launcher-content.xml
@@ -73,9 +73,19 @@
<outputDirectory>bin</outputDirectory>
<includes>
<include>camel.sh</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ <lineEnding>unix</lineEnding>
+ </fileSet>
+ <!-- cmd.exe can miss goto and call :label targets in a batch file
with LF line endings -->
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <includes>
<include>camel.bat</include>
</includes>
<fileMode>0755</fileMode>
+ <lineEnding>dos</lineEnding>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/examples</directory>
diff --git a/dsl/camel-jbang/camel-launcher/src/main/resources/bin/camel.bat
b/dsl/camel-jbang/camel-launcher/src/main/resources/bin/camel.bat
index 28ea94c7a7ee..9453941f1992 100644
--- a/dsl/camel-jbang/camel-launcher/src/main/resources/bin/camel.bat
+++ b/dsl/camel-jbang/camel-launcher/src/main/resources/bin/camel.bat
@@ -188,11 +188,12 @@ if not defined _RAW exit /b 1
:tryJavaParseVersion
set "_RAW=%_RAW:"=%"
set "_MAJOR="
-for /f "tokens=1,2 delims=." %%a in ("%_RAW%") do (
+@REM The major is before the first dot, dash or plus: 21.0.5, 26-ea and 21+35
are 21, 26 and 21 (as camel.sh reads them).
+for /f "tokens=1,2 delims=.-+" %%a in ("%_RAW%") do (
if "%%a"=="1" (set "_MAJOR=%%b") else (set "_MAJOR=%%a")
)
if not defined _MAJOR exit /b 1
-@REM Reject non-numeric majors (e.g. early-access "17-ea") so the numeric
compare below is safe.
+@REM Reject a major that is still not a number, so the numeric compare below
is safe.
for /f "delims=0123456789" %%z in ("%_MAJOR%") do exit /b 1
if %_MAJOR% LSS %CAMEL_MIN_JAVA% exit /b 1
set "CAMEL_JAVACMD=%_CAND%"
diff --git
a/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelBatDiscoveryTest.java
b/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelBatDiscoveryTest.java
index 855f6628c174..e94d85e3d8ea 100644
---
a/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelBatDiscoveryTest.java
+++
b/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelBatDiscoveryTest.java
@@ -52,6 +52,7 @@ class CamelBatDiscoveryTest {
private static final String JAVA25 = "openjdk version \"25\" 2025-09-16";
private static final String JAVA17 = "openjdk version \"17.0.2\"
2022-01-18";
private static final String JAVA17_EA = "openjdk version \"17-ea\"";
+ private static final String JAVA26_EA = "openjdk version \"26-ea\"
2026-03-17";
private static final String JAVA11 = "openjdk version \"11.0.20\"
2023-07-18";
private static final String JAVA8 = "java version \"1.8.0_202\"";
private static final String GARBAGE = "totally not a java banner";
@@ -397,7 +398,24 @@ class CamelBatDiscoveryTest {
}
@Test
- void rejectsNonnumericMajorAndContinuesToFallback(@TempDir Path base)
throws Exception {
+ void acceptsAnEarlyAccessJdkOfARecentVersion(@TempDir Path base) throws
Exception {
+ // 26-ea is Java 26, as camel.sh reads it (CAMEL-26933)
+ Path h = home(base);
+ Path earlyAccess =
FakeJava.writeFakeJava(base.resolve("early-access"), "java", JAVA26_EA, 0,
"EARLY");
+ Path fallback = FakeJava.writeFakeJava(base.resolve("fallback"),
"java", JAVA21, 0, "FALLBACK");
+ Map<String, String> env = isolatedEnvironment();
+ env.put("JAVACMD", earlyAccess.toString());
+ env.put("CAMEL_FALLBACK_JAVA", fallback.toString());
+
+ FakeJava.Result r = FakeJava.run(h.resolve("camel.bat"), env,
"version");
+
+ assertEquals(0, r.exitCode(), r.stderr());
+ assertTrue(r.stdout().contains("RAN=EARLY"), r.stdout());
+ }
+
+ @Test
+ void rejectsAnEarlyAccessJdkBelowTheMinimumAndContinuesToFallback(@TempDir
Path base) throws Exception {
+ // 17-ea is Java 17 (the version is split on the dash too), which is
below the minimum
Path h = home(base);
Path earlyAccess =
FakeJava.writeFakeJava(base.resolve("early-access"), "java", JAVA17_EA, 0,
"EARLY");
Path fallback = FakeJava.writeFakeJava(base.resolve("fallback"),
"java", JAVA21, 0, "FALLBACK");
diff --git
a/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/LauncherArchiveLayoutIT.java
b/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/LauncherArchiveLayoutIT.java
index c257fd5685d7..8fde9b035982 100644
---
a/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/LauncherArchiveLayoutIT.java
+++
b/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/LauncherArchiveLayoutIT.java
@@ -18,6 +18,7 @@ package org.apache.camel.dsl.jbang.launcher;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -88,6 +89,27 @@ class LauncherArchiveLayoutIT {
}
}
+ @Test
+ void theScriptsHaveTheLineEndingsOfTheirSystem() throws IOException {
+ // cmd.exe can miss goto and call :label targets in a batch file with
LF line endings (CAMEL-26933)
+ for (Path zip : binZips()) {
+ try (ZipFile archive = new ZipFile(zip.toFile())) {
+ String bat = script(archive, "camel.bat");
+ assertThat(bat).as("bin/camel.bat of " +
zip.getFileName()).contains("\r\n");
+ assertThat(bat.replace("\r\n", "")).as("a line of
bin/camel.bat without CR in " + zip.getFileName())
+ .doesNotContain("\n");
+ assertThat(script(archive, "camel.sh")).as("bin/camel.sh of "
+ zip.getFileName()).doesNotContain("\r");
+ }
+ }
+ }
+
+ private static String script(ZipFile archive, String name) throws
IOException {
+ ZipEntry entry = archive.stream().filter(e ->
e.getName().endsWith("/bin/" + name)).findFirst().orElseThrow();
+ try (InputStream in = archive.getInputStream(entry)) {
+ return new String(in.readAllBytes(), StandardCharsets.UTF_8);
+ }
+ }
+
private static List<Path> binZips() throws IOException {
try (Stream<Path> paths = Files.list(TARGET)) {
return new ArrayList<>(