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 1226de01136 CAMEL-22131: camel-jbang: Cannot export on windows unless
using --maven-wrapper=false (#18246)
1226de01136 is described below
commit 1226de011363167a2acc4fe42617a7acffdf3f7c
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Jun 2 17:07:19 2025 +0200
CAMEL-22131: camel-jbang: Cannot export on windows unless using
--maven-wrapper=false (#18246)
---
.../src/main/java/org/apache/camel/util/FileUtil.java | 19 +++++++++++++++++++
.../dsl/jbang/core/commands/ExportBaseCommand.java | 9 ++++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
index 545bac567e6..32162e6fc9f 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;
@@ -626,6 +627,24 @@ public final class FileUtil {
}
}
+ /**
+ * Set posix file permissions
+ *
+ * @param path the file
+ * @param permissions permissions such as: rwxr-xr-x
+ * @return true if permission was set or false if the
file-system does not support posix (such as
+ * windows)
+ */
+ public static boolean setPosixFilePermissions(Path path, String
permissions) throws IOException {
+ try {
+ Files.setPosixFilePermissions(path,
PosixFilePermissions.fromString(permissions));
+ return true;
+ } catch (UnsupportedOperationException e) {
+ // ignore
+ }
+ return false;
+ }
+
/**
* Determines whether the URI has a scheme (e.g. file:, classpath: or
http:)
*
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index 6d5207cf685..12827ad8e60 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -24,7 +24,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
-import java.nio.file.attribute.PosixFilePermissions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -864,8 +863,8 @@ public abstract class ExportBaseCommand extends
CamelCommand {
}
// set execute file permission on mvnw/mvnw.cmd files
- Files.setPosixFilePermissions(mvnwPath,
PosixFilePermissions.fromString("rwxr-xr-x"));
- Files.setPosixFilePermissions(mvnwCmdPath,
PosixFilePermissions.fromString("rwxr-xr-x"));
+ FileUtil.setPosixFilePermissions(mvnwPath, "rwxr-xr-x");
+ FileUtil.setPosixFilePermissions(mvnwCmdPath, "rwxr-xr-x");
}
protected void copyGradleWrapper() throws Exception {
@@ -893,8 +892,8 @@ public abstract class ExportBaseCommand extends
CamelCommand {
}
// set execute file permission on gradlew/gradlew.bat files
- Files.setPosixFilePermissions(gradlewPath,
PosixFilePermissions.fromString("rwxr-xr-x"));
- Files.setPosixFilePermissions(gradlewBatPath,
PosixFilePermissions.fromString("rwxr-xr-x"));
+ FileUtil.setPosixFilePermissions(gradlewPath, "rwxr-xr-x");
+ FileUtil.setPosixFilePermissions(gradlewBatPath, "rwxr-xr-x");
}
protected String applicationPropertyLine(String key, String value) {