This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 98bad68ff6 Respect PATHEXT and path.separator in executable profile 
activation (#14063)
98bad68ff6 is described below

commit 98bad68ff624602bda097367ae48528f74efb8a9
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Mon Nov 23 09:43:09 2026 +0100

    Respect PATHEXT and path.separator in executable profile activation (#14063)
    
    * Respect PATHEXT and path.separator in executable profile activation
    
    * Fix absolute path detection on Windows and clarify path.separator comment
    
    On Windows, absolute paths like 'C:\Users\...' contain '\' but no '/'.
    The previous check '(windows && name.contains("\\))' used the simulated
    'windows' flag from os.name in the activation context, which may not be set
    when testing with a real Windows absolute path. A backslash in a name always
    indicates a path component separator and must trigger the direct-path code
    path regardless of the OS simulation state.
    
    Also add a clarifying comment explaining why path.separator is read from the
    activation context (cross-OS unit testing) as suggested by review.
    
    * Fix Windows IT test: write script to file instead of passing via -c
    
    Java's ProcessBuilder on Windows uses CreateProcess which mangles multi-line
    bash scripts with nested double-quotes when passed as a -c argument. The
    resulting script visible to bash has broken quoting, causing 'unexpected EOF
    while looking for matching )' on line 7.
    
    Write the script to a temporary file and pass the file path to bash instead.
    Also remove nested double-quote patterns in the script (use ${var} instead
    of "$var" inside command substitutions) to be more robust.
    
    * Use native OS in executable absolute-path tests
    
    * Apply Spotless formatting to ExecutableFinderTest
    
    * Document the path.separator override in ExecutableFinder
    
    * Rename executable activation ITs to the GH-10115 convention
    
    * Remove final from method parameters and local variables
    
    * Remove final from local variables in 
testExecutableWithCustomWindowsExtensionAndCombinedCondition
    
    ---------
    
    Co-authored-by: Guillaume Nodet <[email protected]>
---
 api/maven-api-model/src/main/mdo/maven.mdo         |  30 +++
 .../impl/model/profile/ConditionFunctions.java     |  26 ++-
 .../maven/impl/model/profile/ExecutableFinder.java | 186 ++++++++----------
 .../profile/ConditionProfileActivatorTest.java     |  17 +-
 .../impl/model/profile/ExecutableFinderTest.java   | 132 +++++++++++--
 .../MavenITgh10115ExecutableWindowsShellTest.java  | 216 +++++++++++++++++++++
 ...ITgh10115ProfileActivationByExecutableTest.java | 170 ++++++++++++++++
 .../pom.xml                                        |  70 +++++++
 8 files changed, 724 insertions(+), 123 deletions(-)

diff --git a/api/maven-api-model/src/main/mdo/maven.mdo 
b/api/maven-api-model/src/main/mdo/maven.mdo
index b65d532c81..50cb9ffed7 100644
--- a/api/maven-api-model/src/main/mdo/maven.mdo
+++ b/api/maven-api-model/src/main/mdo/maven.mdo
@@ -3101,9 +3101,37 @@
             <li>{@code if(condition, trueValue, falseValue)}: Returns 
trueValue if the condition is true, falseValue otherwise.</li>
             <li>{@code exists(path)}: Checks if a file matching the given glob 
pattern exists.</li>
             <li>{@code missing(path)}: Checks if a file matching the given 
glob pattern does not exist.</li>
+            <li>{@code executable(name)}: Checks whether an executable file is 
available by name on {@code PATH} or at an explicit path, without executing 
it.</li>
             <li>{@code inrange(version, range)}: Checks if the given version 
is within the specified version range.</li>
             </ul>
 
+            <h3>Executable Availability</h3>
+
+            <p>{@code executable('docker')} checks for the Docker client 
executable, not whether
+            the Docker daemon is running or reachable. The executable is never 
run.</p>
+
+            <p>A plain name is searched for in the directories listed in 
{@code PATH}; empty
+            entries are ignored rather than treated as the current directory. 
An explicit
+            absolute or relative path is checked directly, without searching 
{@code PATH}.
+            On Windows, suffix probing also applies to explicit paths.</p>
+
+            <p>On Windows, Maven normalizes environment variable names to 
uppercase, so
+            {@code PATH} and {@code Path} are exposed as {@code env.PATH}. For 
plain-name
+            searches, the exact filename is checked first, followed by suffix 
probing using
+            {@code PATHEXT}. Its semicolon-separated entries are trimmed and 
deduplicated
+            case-insensitively, with empty entries ignored. The fallback
+            {@code .COM;.EXE;.BAT;.CMD} is used only when {@code PATHEXT} is 
absent;
+            an explicitly empty {@code PATHEXT} disables suffix probing.</p>
+
+            <p>This also applies when Maven is launched from Git Bash or 
Cygwin on Windows:
+            the shell runtime converts its POSIX {@code PATH} to native 
Windows paths when
+            starting the Windows JVM. Executable lookup uses that native path 
list, not
+            shell aliases or functions.</p>
+
+            <p><strong>Warning:</strong> relying on local system environment 
variables like
+            {@code PATH} makes profile activation non-reproducible. Use this 
function primarily
+            in local build profiles, not in consumer POMs published to a 
remote repository.</p>
+
             <h2>Supported properties</h2>
 
             <p>The following properties are supported in expressions:</p>
@@ -3123,6 +3151,8 @@
             <li>JDK version range: {@code inrange(${java.version}, '[11,)')} 
(JDK 11 or higher)</li>
             <li>OS check: {@code ${os.name} == 'windows'}</li>
             <li>File existence: {@code 
exists('${project.basedir}/src/**}{@code /*.xsd')}</li>
+            <li>Docker client availability: {@code executable('docker')}</li>
+            <li>Explicit executable path: {@code 
executable('/usr/bin/docker')}</li>
             <li>Property check: {@code ${my.property} != 'some-value'}</li>
             <li>Regex matching: {@code matches(${os.version}, '.*aws')}</li>
             <li>Complex condition: {@code ${os.name} == 'windows' && 
${os.arch} != 'amd64' && inrange(${os.version}, '[10,)')}</li>
diff --git 
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java
 
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java
index 1ee2f04231..24523241ff 100644
--- 
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java
+++ 
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java
@@ -246,8 +246,10 @@ public Object inrange(List<Object> args) {
     }
 
     /**
-     * Checks whether a given executable can be found in the system PATH, or – 
if an
-     * absolute / relative path is supplied – whether that path itself is an 
executable file.
+     * Checks whether a given executable can be found in the system {@code 
PATH}, or whether
+     * an explicit absolute or relative path identifies an executable file.
+     * The executable is never run. For example, {@code executable('docker')} 
checks for the
+     * Docker client executable, not whether the Docker daemon is running or 
reachable.
      *
      * <p><strong>Warning:</strong> relying on local system environment 
variables like PATH makes
      * profile activation non-reproducible. This function should typically be 
used only in local
@@ -255,15 +257,27 @@ public Object inrange(List<Object> args) {
      *
      * <p>Usage examples in a profile {@code <condition>}:
      * <pre>
+     *   executable('docker')
+     *   executable('/usr/bin/docker')
      *   executable('musl-gcc')
      *   executable('x86_64-linux-musl-gcc')
      *   executable('/usr/bin/musl-gcc')
      * </pre>
      *
-     * <p>When a plain name (without path separators) is given the function 
searches every
-     * directory listed in the {@code PATH} environment variable.  On Windows, 
the platform
-     * executable extensions ({@code .exe}, {@code .cmd}, {@code .bat}, {@code 
.com}) are
-     * tried automatically when the name does not already carry an extension.
+     * <p>When a plain name (without path separators) is given, the function 
searches the
+     * directories listed in the {@code PATH} environment variable. Empty 
entries are ignored,
+     * not treated as the current directory. Explicit paths are checked 
directly, without
+     * searching {@code PATH}. On Windows, suffix probing also applies to 
explicit paths.</p>
+     *
+     * <p>On Windows, Maven normalizes environment variable names to 
uppercase, so {@code PATH}
+     * and {@code Path} are exposed as {@code env.PATH}. For plain-name 
searches, the exact
+     * filename is checked first, followed by suffix probing using {@code 
PATHEXT}. Its
+     * semicolon-separated entries are trimmed and deduplicated 
case-insensitively, with empty
+     * entries ignored. The fallback {@code .COM;.EXE;.BAT;.CMD} is used only 
when {@code PATHEXT}
+     * is absent; an explicitly empty {@code PATHEXT} disables suffix 
probing.</p>
+     *
+     * <p>Git Bash and Cygwin convert their POSIX {@code PATH} when starting 
native Windows
+     * Java. Lookup uses that native path list, not shell aliases or 
functions.</p>
      *
      * @param args A list containing a single string argument: the executable 
name or path
      * @return {@code true} if the executable is found and is a regular, 
executable file,
diff --git 
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ExecutableFinder.java
 
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ExecutableFinder.java
index d004c86e25..1c0f41cc82 100644
--- 
a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ExecutableFinder.java
+++ 
b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ExecutableFinder.java
@@ -20,144 +20,128 @@
 
 import java.io.File;
 import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
 import java.nio.file.Path;
+import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Locale;
+import java.util.regex.Pattern;
 
 import org.apache.maven.api.services.model.ProfileActivationContext;
 
 /**
- * Helper that implements the OS-aware PATH search used by the {@code 
executable()} condition function.
- *
- * <p>The search strategy is:
- * <ol>
- *   <li>If {@code name} contains a path separator (i.e. it already looks like 
a path), treat it as
- *       an absolute or relative file path and check it directly.</li>
- *   <li>Otherwise, retrieve the {@code PATH} value from the activation 
context's system properties
- *       (Maven normalises env vars to {@code env.PATH} / {@code env.Path} 
etc.) and split it by the
- *       platform path separator.  Each directory is searched in order.</li>
- *   <li>On Windows, when the candidate does not already have one of the known 
executable extensions
- *       ({@code .exe}, {@code .cmd}, {@code .bat}, {@code .com}), those 
extensions are appended and
- *       tried as well.</li>
- * </ol>
+ * OS-aware PATH search used by the {@code executable()} condition function.
+ * Explicit paths are checked directly; plain names are searched only in 
nonempty PATH entries.
+ * Maven normalizes Windows environment variable names, including {@code 
Path}, to {@code env.PATH}.
+ * On Windows, quoted PATH directories are supported and suffixes from {@code 
env.PATHEXT} are
+ * tried in order, unless the name already has one of those suffixes. An 
absent PATHEXT defaults
+ * to {@code .COM;.EXE;.BAT;.CMD}; an empty PATHEXT disables suffix probing.
+ * Exact files are checked before appending suffixes, preserving explicit-file 
support.
+ * No executable is launched and no implicit current-directory search is 
performed.
+ * <p>
+ * {@code env.PATH} is split on the {@code path.separator} system property, 
falling back to
+ * {@link File#pathSeparator} when it is missing or empty.
+ * At runtime both values are identical, so the property is only an override 
point: it allows the unit tests
+ * to exercise Windows and POSIX separators independently of the host OS, and 
copes with environments that
+ * explicitly set {@code path.separator}.
  *
  * @since 4.x
  */
 class ExecutableFinder {
 
-    /** Windows-specific executable file extensions, in search order. */
-    private static final String[] WINDOWS_EXTENSIONS = {".exe", ".cmd", 
".bat", ".com"};
-
-    /** The system property key under which Maven exposes the {@code PATH} 
environment variable. */
-    private static final String ENV_PATH_KEY = "env.PATH";
+    private static final String DEFAULT_WINDOWS_EXTENSIONS = 
".COM;.EXE;.BAT;.CMD";
 
     private ExecutableFinder() {}
 
     /**
-     * Returns {@code true} when {@code name} resolves to an executable file.
+     * Checks for a regular executable file without running it.
      *
-     * @param name    the executable name (e.g. {@code "musl-gcc"}) or an 
absolute/relative path
-     * @param context the current profile activation context
-     * @return {@code true} if the executable is found and is a regular, 
executable file
+     * @param name executable name or absolute/relative path
+     * @param context current activation context, including environment 
properties
+     * @return whether the executable can be found
      */
     static boolean isExecutableInPath(String name, ProfileActivationContext 
context) {
-        boolean isWindows = isWindows(context);
-
-        // If the name already contains a path separator treat it as a direct 
path.
-        if (name.contains("/") || name.contains(File.separator)) {
-            Path candidate = Path.of(name);
-            if (isExecutableFile(candidate, isWindows)) {
-                return true;
-            }
-            // On Windows also try known executable extensions for direct 
paths.
-            if (isWindows && !hasWindowsExtension(name)) {
-                for (String ext : WINDOWS_EXTENSIONS) {
-                    if (isExecutableFile(Path.of(name + ext), isWindows)) {
-                        return true;
-                    }
-                }
-            }
+        if (name == null || name.isBlank()) {
             return false;
         }
+        var windows = isWindows(context);
+        var extensions = windows ? windowsExtensions(context) : 
List.<String>of();
 
-        // --- plain name: search PATH ---
-        String pathValue = getPathValue(context);
+        if (name.contains("/") || name.contains("\\")) {
+            return matches(null, name, windows, extensions);
+        }
+
+        var pathValue = context.getSystemProperty("env.PATH");
         if (pathValue == null || pathValue.isBlank()) {
             return false;
         }
-
-        String[] dirs = pathValue.split(File.pathSeparator, -1);
-        for (String dir : dirs) {
-            if (dir.isBlank()) {
-                continue;
+        var separator = context.getSystemProperty("path.separator");
+        // path.separator may be overridden in tests to simulate a non-native 
host OS;
+        // at runtime it always matches File.pathSeparator.
+        var pathSeparator = separator == null || separator.isEmpty() ? 
File.pathSeparator : separator;
+        var delimiter =
+                ":".equals(pathSeparator) || ";".equals(pathSeparator) ? 
pathSeparator : Pattern.quote(pathSeparator);
+        for (String directory : pathValue.split(delimiter, -1)) {
+            if (windows && directory.length() >= 2 && 
directory.startsWith("\"") && directory.endsWith("\"")) {
+                directory = directory.substring(1, directory.length() - 1);
             }
-            Path base = Path.of(dir).resolve(name);
-            if (isExecutableFile(base, isWindows)) {
+            if (!directory.isBlank() && matches(directory, name, windows, 
extensions)) {
                 return true;
             }
-            // On Windows also try known executable extensions (unless already 
present).
-            if (isWindows && !hasWindowsExtension(name)) {
-                for (String ext : WINDOWS_EXTENSIONS) {
-                    Path withExt = Path.of(dir).resolve(name + ext);
-                    if (isExecutableFile(withExt, isWindows)) {
-                        return true;
-                    }
-                }
-            }
         }
         return false;
     }
 
-    // -----------------------------------------------------------------------
-    // Package-private helpers (visible to tests)
-    // -----------------------------------------------------------------------
-
-    /**
-     * Retrieves the PATH value from the activation context.
-     *
-     * <p>Maven places env vars in system properties as {@code env.<NAME>}.
-     * On Windows, env var names are normalised to upper-case (e.g. {@code 
env.PATH}).
-     *
-     * @param context the profile activation context
-     * @return the raw PATH string, or {@code null} if not available
-     */
-    static String getPathValue(ProfileActivationContext context) {
-        return context.getSystemProperty(ENV_PATH_KEY);
-    }
-
-    // -----------------------------------------------------------------------
-    // Private utilities
-    // -----------------------------------------------------------------------
-
-    private static boolean isWindows(ProfileActivationContext context) {
-        String osName = context.getSystemProperty("os.name");
-        return osName != null && 
osName.toLowerCase(Locale.ROOT).contains("windows");
-    }
-
-    /**
-     * Returns {@code true} if {@code path} is a regular file that the JVM 
considers executable.
-     *
-     * <p>On Windows, {@link Files#isExecutable(Path)} always returns {@code 
true} for regular
-     * files, so this method simply checks that the file exists and is 
regular.  The caller is
-     * responsible for probing Windows executable extensions ({@code .exe}, 
{@code .cmd}, etc.)
-     * when the user-supplied name does not already carry one.  On Unix/POSIX 
systems the
-     * execute permission bit is checked via {@link 
Files#isExecutable(Path)}.</p>
-     */
-    private static boolean isExecutableFile(Path path, boolean isWindows) {
-        if (!Files.isRegularFile(path)) {
-            return false;
+    private static List<String> windowsExtensions(ProfileActivationContext 
context) {
+        var value = context.getSystemProperty("env.PATHEXT");
+        var extensions = new LinkedHashSet<String>();
+        for (var entry : (value == null ? DEFAULT_WINDOWS_EXTENSIONS : 
value).split(";")) {
+            var extension = entry.trim().toLowerCase(Locale.ROOT);
+            // PATHEXT entries are suffixes, not paths. Ignore malformed 
entries.
+            if (extension.startsWith(".")
+                    && extension.length() > 1
+                    && !extension.contains("/")
+                    && !extension.contains("\\")
+                    && !extension.contains(":")
+                    && extension.indexOf('\0') < 0) {
+                extensions.add(extension);
+            }
         }
-        // On Windows Files.isExecutable() always returns true for regular 
files.
-        // On Unix we rely on the execute permission bit.
-        return isWindows || Files.isExecutable(path);
+        return List.copyOf(extensions);
     }
 
-    private static boolean hasWindowsExtension(String name) {
-        String lower = name.toLowerCase(Locale.ROOT);
-        for (String ext : WINDOWS_EXTENSIONS) {
-            if (lower.endsWith(ext)) {
+    private static boolean matches(String directory, String name, boolean 
windows, List<String> extensions) {
+        try {
+            var candidate =
+                    directory == null ? Path.of(name) : 
Path.of(directory).resolve(name);
+            if (isExecutableFile(candidate, windows)) {
                 return true;
             }
+            var lowerName = name.toLowerCase(Locale.ROOT);
+            if (extensions.stream().anyMatch(lowerName::endsWith)) {
+                return false;
+            }
+            for (var extension : extensions) {
+                var withExtension = directory == null
+                        ? Path.of(name + extension)
+                        : Path.of(directory).resolve(name + extension);
+                if (isExecutableFile(withExtension, windows)) {
+                    return true;
+                }
+            }
+        } catch (InvalidPathException e) {
+            // An invalid PATH entry must not hide executables in subsequent 
directories.
         }
         return false;
     }
+
+    private static boolean isWindows(ProfileActivationContext context) {
+        var osName = context.getSystemProperty("os.name");
+        return osName != null && 
osName.toLowerCase(Locale.ROOT).contains("windows");
+    }
+
+    private static boolean isExecutableFile(Path path, boolean windows) {
+        // Windows uses PATHEXT rather than the POSIX execute permission bit.
+        return Files.isRegularFile(path) && (windows || 
Files.isExecutable(path));
+    }
 }
diff --git 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
index 41d0156b8a..949ed6be0d 100644
--- 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
+++ 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
@@ -538,7 +538,8 @@ void testExecutableWithAbsolutePath() throws Exception {
         Profile profile = newProfile("executable('" + absPath + "')");
 
         // PATH content does not matter for absolute paths
-        assertActivation(true, profile, newContext(null, Map.of("env.PATH", 
"")));
+        assertActivation(
+                true, profile, newContext(null, Map.of("env.PATH", "", 
"os.name", System.getProperty("os.name"))));
     }
 
     /**
@@ -565,4 +566,18 @@ void testExecutableNegated() throws Exception {
         assertActivation(false, newProfile("not(executable('neg-tool'))"), 
newContext(null, sysProps));
         assertActivation(true, 
newProfile("not(executable('no-such-neg-tool'))"), newContext(null, sysProps));
     }
+
+    @Test
+    void testExecutableWithCustomWindowsExtensionAndCombinedCondition() throws 
Exception {
+        Files.createFile(tempDir.resolve("docker.custom"));
+        var sysProps = Map.of(
+                "env.PATH", tempDir.toString(),
+                "env.PATHEXT", ".CUSTOM",
+                "os.name", "Windows 11");
+        var profile = newProfile("executable('docker') && ${enable.docker} == 
'true'");
+        assertActivation(true, profile, newContext(Map.of("enable.docker", 
"true"), sysProps));
+        assertActivation(false, profile, newContext(Map.of("enable.docker", 
"false"), sysProps));
+        assertActivation(false, newProfile("not(executable('docker'))"), 
newContext(null, sysProps));
+        assertActivation(true, 
newProfile("not(executable('missing-docker'))"), newContext(null, sysProps));
+    }
 }
diff --git 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ExecutableFinderTest.java
 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ExecutableFinderTest.java
index b7f20ea627..2b9f68026d 100644
--- 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ExecutableFinderTest.java
+++ 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ExecutableFinderTest.java
@@ -27,10 +27,10 @@
 import org.apache.maven.api.services.model.ProfileActivationContext;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.EnabledOnOs;
 import org.junit.jupiter.api.condition.OS;
 import org.junit.jupiter.api.io.TempDir;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -43,8 +43,7 @@ class ExecutableFinderTest {
     Path tempDir;
 
     /**
-     * Minimal stub – only {@link 
ProfileActivationContext#getSystemProperty(String)} is used
-     * by {@link ExecutableFinder#getPathValue}.
+     * Minimal stub providing isolated environment properties.
      */
     private static ProfileActivationContext contextWithPath(String pathValue) {
         return contextWithPathAndOs(pathValue, null);
@@ -54,6 +53,16 @@ private static ProfileActivationContext 
contextWithPath(String pathValue) {
      * Extended stub that also allows setting {@code os.name} for simulating 
Windows behaviour.
      */
     private static ProfileActivationContext contextWithPathAndOs(String 
pathValue, String osName) {
+        return contextWithPathAndOs(pathValue, osName, null);
+    }
+
+    private static ProfileActivationContext contextWithPathAndOs(String 
pathValue, String osName, String pathExt) {
+        return contextWithPathAndOs(
+                pathValue, osName, pathExt, osName != null && 
osName.startsWith("Windows") ? ";" : File.pathSeparator);
+    }
+
+    private static ProfileActivationContext contextWithPathAndOs(
+            String pathValue, String osName, String pathExt, String separator) 
{
         Map<String, String> props = new HashMap<>();
         if (pathValue != null) {
             props.put("env.PATH", pathValue);
@@ -61,6 +70,12 @@ private static ProfileActivationContext 
contextWithPathAndOs(String pathValue, S
         if (osName != null) {
             props.put("os.name", osName);
         }
+        if (pathExt != null) {
+            props.put("env.PATHEXT", pathExt);
+        }
+        if (separator != null) {
+            props.put("path.separator", separator);
+        }
         return new ProfileActivationContext() {
             @Override
             public boolean isProfileActive(String profileId) {
@@ -125,17 +140,6 @@ public void addProfileProperties(
         };
     }
 
-    // -----------------------------------------------------------------------
-    // getPathValue()
-    // -----------------------------------------------------------------------
-
-    @Test
-    void getPathValueFromContext() {
-        String expected = "/usr/bin" + File.pathSeparator + "/usr/local/bin";
-        ProfileActivationContext ctx = contextWithPath(expected);
-        assertEquals(expected, ExecutableFinder.getPathValue(ctx));
-    }
-
     // -----------------------------------------------------------------------
     // isExecutableInPath() - plain name
     // -----------------------------------------------------------------------
@@ -183,7 +187,8 @@ void findsExecutableByAbsolutePath() throws Exception {
 
         String absPath = exec.toAbsolutePath().toString();
         // Absolute paths contain path separators -> direct check
-        assertTrue(ExecutableFinder.isExecutableInPath(absPath, 
contextWithPath("")));
+        assertTrue(
+                ExecutableFinder.isExecutableInPath(absPath, 
contextWithPathAndOs("", System.getProperty("os.name"))));
     }
 
     @Test
@@ -231,4 +236,101 @@ void doesNotAppendExtensionOnNonWindows() throws 
Exception {
         ProfileActivationContext ctx = 
contextWithPathAndOs(tempDir.toString(), "Linux");
         assertFalse(ExecutableFinder.isExecutableInPath("my-tool", ctx));
     }
+
+    @Test
+    void honorsCustomWindowsPathExt() throws Exception {
+        Files.createFile(tempDir.resolve("docker.custom"));
+        var context = contextWithPathAndOs(tempDir.toString(), "Windows 11", " 
; .CuStOm ;.CUSTOM;;");
+        assertTrue(ExecutableFinder.isExecutableInPath("docker", context));
+        assertTrue(ExecutableFinder.isExecutableInPath("docker.custom", 
context));
+    }
+
+    @Test
+    @EnabledOnOs(OS.WINDOWS)
+    void matchesWindowsFileNamesCaseInsensitively() throws Exception {
+        Files.createFile(tempDir.resolve("DOCKER.ExE"));
+        assertTrue(ExecutableFinder.isExecutableInPath(
+                "docker", contextWithPathAndOs(tempDir.toString(), "Windows 
11", ".EXE")));
+    }
+
+    @Test
+    void respectsExcludedAndEmptyWindowsExtensions() throws Exception {
+        Files.createFile(tempDir.resolve("docker.exe"));
+        assertFalse(ExecutableFinder.isExecutableInPath(
+                "docker", contextWithPathAndOs(tempDir.toString(), "Windows 
11", ".CMD")));
+        assertFalse(ExecutableFinder.isExecutableInPath(
+                "docker", contextWithPathAndOs(tempDir.toString(), "Windows 
11", "")));
+        assertTrue(ExecutableFinder.isExecutableInPath(
+                "docker.exe", contextWithPathAndOs(tempDir.toString(), 
"Windows 11", "")));
+    }
+
+    @Test
+    void usesWindowsDelimiterAndQuotedDirectories() throws Exception {
+        var directory = Files.createDirectory(tempDir.resolve("directory with 
spaces"));
+        Files.createFile(directory.resolve("docker.cmd"));
+        var path = ";" + tempDir.resolve("missing") + ";\"" + directory + 
"\";;";
+        assertTrue(ExecutableFinder.isExecutableInPath("docker", 
contextWithPathAndOs(path, "Windows 11", ".CMD")));
+    }
+
+    @Test
+    void usesLiteralSeparatorFromContextIndependentlyOfOsName() throws 
Exception {
+        Files.createFile(tempDir.resolve("docker.cmd"));
+        var path = tempDir.resolve("missing") + "|" + tempDir;
+        assertTrue(
+                ExecutableFinder.isExecutableInPath("docker", 
contextWithPathAndOs(path, "Windows 11", ".CMD", "|")));
+        assertFalse(
+                ExecutableFinder.isExecutableInPath("docker", 
contextWithPathAndOs(path, "Windows 11", ".CMD", ";")));
+    }
+
+    @Test
+    void fallsBackToNativeSeparatorWhenPropertyIsMissingOrEmpty() throws 
Exception {
+        Files.createFile(tempDir.resolve("docker.cmd"));
+        var path = tempDir.resolve("missing") + File.pathSeparator + tempDir;
+        assertTrue(
+                ExecutableFinder.isExecutableInPath("docker", 
contextWithPathAndOs(path, "Windows 11", ".CMD", null)));
+        assertTrue(ExecutableFinder.isExecutableInPath("docker", 
contextWithPathAndOs(path, "Windows 11", ".CMD", "")));
+    }
+
+    @Test
+    void ignoresInvalidPathEntries() throws Exception {
+        Files.createFile(tempDir.resolve("docker.cmd"));
+        assertTrue(ExecutableFinder.isExecutableInPath(
+                "docker", contextWithPathAndOs("bad\0directory;" + tempDir, 
"Windows 11", ".CMD")));
+    }
+
+    @Test
+    void rejectsInvalidExplicitPathsAndExtensionEntries() throws Exception {
+        Files.createFile(tempDir.resolve("docker.cmd"));
+        var context = contextWithPathAndOs(tempDir.toString(), "Windows 11", 
".bad\0;.bad/path;.bad\\path;.bad:path");
+        assertFalse(ExecutableFinder.isExecutableInPath("docker", context));
+        assertFalse(ExecutableFinder.isExecutableInPath("bad\0/path", 
context));
+    }
+
+    @Test
+    void probesExtensionsForExplicitPaths() throws Exception {
+        Files.createFile(tempDir.resolve("docker.custom"));
+        assertTrue(ExecutableFinder.isExecutableInPath(
+                tempDir.resolve("docker").toString(), contextWithPathAndOs("", 
"Windows 11", ".CUSTOM")));
+    }
+
+    @Test
+    void rejectsDirectoriesAndMissingPath() throws Exception {
+        Files.createDirectory(tempDir.resolve("docker.exe"));
+        assertFalse(ExecutableFinder.isExecutableInPath(
+                "docker", contextWithPathAndOs(tempDir.toString(), "Windows 
11", ".EXE")));
+        assertFalse(ExecutableFinder.isExecutableInPath("docker", 
contextWithPath(null)));
+        assertFalse(ExecutableFinder.isExecutableInPath("", 
contextWithPath(tempDir.toString())));
+        assertFalse(ExecutableFinder.isExecutableInPath(null, 
contextWithPath(tempDir.toString())));
+    }
+
+    @Test
+    @DisabledOnOs(OS.WINDOWS)
+    void searchesMultiplePosixDirectoriesWithoutTrimmingSpaces() throws 
Exception {
+        var directory = Files.createDirectory(tempDir.resolve(" directory with 
spaces "));
+        var executable = Files.createFile(directory.resolve("docker"));
+        assertTrue(executable.toFile().setExecutable(true));
+        var path = ":bad\0directory:" + tempDir.resolve("missing") + ":" + 
directory + "::";
+        assertTrue(ExecutableFinder.isExecutableInPath("docker", 
contextWithPathAndOs(path, "Linux")));
+        assertFalse(ExecutableFinder.isExecutableInPath("docker", 
contextWithPathAndOs(tempDir.toString(), "Linux")));
+    }
 }
diff --git 
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10115ExecutableWindowsShellTest.java
 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10115ExecutableWindowsShellTest.java
new file mode 100644
index 0000000000..c967dedc6f
--- /dev/null
+++ 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10115ExecutableWindowsShellTest.java
@@ -0,0 +1,216 @@
+/*
+ * 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.maven.it;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
+/**
+ * Exercises executable() through the real POSIX launcher with a native 
Windows JVM.
+ * Optional shell locations can be supplied as JVM properties maven.it.gitBash 
and maven.it.cygwinBash.
+ */
+@EnabledOnOs(OS.WINDOWS)
+class MavenITgh10115ExecutableWindowsShellTest extends 
AbstractMavenIntegrationTestCase {
+    private static final String COMMAND = "gh10115-profile-tool";
+    private static final String DEFAULT_PATHEXT = ".COM;.EXE;.BAT;.CMD";
+    // Written to a temp file to avoid Windows CreateProcess argument-quoting 
issues
+    // when passing multi-line scripts with double quotes via ProcessBuilder + 
-c.
+    private static final String SCRIPT = """
+            set -eu
+            # Never expose the inherited host PATH, even in the 
missing-command case.
+            export PATH=/usr/bin:/bin
+            fake_path=$(cygpath --unix --path "${IT_FAKE_PATH}")
+            export PATH="/usr/bin:/bin:${fake_path}"
+            export JAVA_HOME=$(cygpath --unix "${IT_JAVA_HOME}")
+            export MAVEN_HOME=$(cygpath --unix "${IT_MAVEN_HOME}")
+            export MAVEN_SKIP_RC=true
+            unset MAVEN_OPTS MAVEN_ARGS MAVEN_CONFIG MAVEN_PROJECTBASEDIR
+            exec "${MAVEN_HOME}/bin/mvn" -B -e --install-settings 
"${IT_SETTINGS}" "-Dmaven.repo.local=${IT_REPO}" "-Duser.home=${IT_USER_HOME}" 
validate
+            """;
+
+    @Test
+    void testGitBash() throws Exception {
+        var candidates = new ArrayList<Path>();
+        for (var variable : new String[] {"ProgramFiles", "ProgramFiles(x86)", 
"LOCALAPPDATA"}) {
+            var root = System.getenv(variable);
+            if (root != null && !root.isBlank()) {
+                candidates.add(Path.of(root, variable.equals("LOCALAPPDATA") ? 
"Programs/Git" : "Git", "bin/bash.exe"));
+            }
+        }
+        candidates.add(Path.of("C:/Program Files/Git/bin/bash.exe"));
+        verifyShell(findShell("maven.it.gitBash", candidates));
+    }
+
+    @Test
+    void testCygwin() throws Exception {
+        var drive = System.getenv().getOrDefault("SystemDrive", "C:");
+        verifyShell(findShell(
+                "maven.it.cygwinBash",
+                List.of(Path.of(drive + "/cygwin64/bin/bash.exe"), 
Path.of(drive + "/cygwin/bin/bash.exe"))));
+    }
+
+    private Path findShell(String property, Iterable<Path> candidates) {
+        var configured = System.getProperty(property);
+        if (configured != null) {
+            assertFalse(configured.isBlank(), property + " must name a 
bash.exe file");
+            var shell = Path.of(configured).toAbsolutePath();
+            assertTrue(Files.isRegularFile(shell) && 
Files.isExecutable(shell), property + " is invalid: " + shell);
+            return shell;
+        }
+        for (var candidate : candidates) {
+            if (Files.isRegularFile(candidate) && 
Files.isExecutable(candidate)) {
+                return candidate.toAbsolutePath();
+            }
+        }
+        assumeTrue(
+                false, "Shell not installed; set -D" + property + "=<absolute 
path to bash.exe> to enable this test");
+        throw new IllegalStateException("Unreachable after failed assumption");
+    }
+
+    private void verifyShell(Path shell) throws Exception {
+        verifyActivation(shell, ".cmd", DEFAULT_PATHEXT, true);
+        verifyActivation(shell, ".exe", DEFAULT_PATHEXT, true);
+        verifyActivation(shell, ".gh10115", DEFAULT_PATHEXT + ";.GH10115", 
true);
+        verifyActivation(shell, ".gh10115", DEFAULT_PATHEXT, false);
+        verifyActivation(shell, null, DEFAULT_PATHEXT + ";.GH10115", false);
+    }
+
+    private void verifyActivation(Path shell, String suffix, String pathExt, 
boolean active) throws Exception {
+        var fixture = 
extractResources("gh-10115-profile-activation-by-executable");
+        var project = Files.createTempDirectory(fixture, getName() + 
"-").toAbsolutePath();
+        // The unique command name avoids collisions with tools installed in 
the shell's own bin directories.
+        Files.copy(fixture.resolve("pom.xml"), project.resolve("pom.xml"));
+        var fakeBin = Files.createDirectory(project.resolve("fake bin with 
spaces"));
+        if (suffix != null) {
+            // Detection only: an accidental shell/batch invocation leaves 
evidence and exits unsuccessfully.
+            var content = suffix.equals(".cmd")
+                    ? "@echo executed>\"%~dp0..\\executed\"\r\n@exit /b 97\r\n"
+                    : "#!/bin/sh\n: > \"${0%/*}/../executed\"\nexit 97\n";
+            Files.writeString(fakeBin.resolve(COMMAND + suffix), content);
+        }
+
+        var log = project.resolve("mvn-output.txt");
+        // Write the script to a file to avoid Windows CreateProcess 
argument-quoting
+        // issues when passing multi-line scripts with double quotes via -c.
+        var scriptFile = project.resolve("run-maven.sh");
+        Files.writeString(scriptFile, SCRIPT, StandardCharsets.UTF_8);
+        var builder = new ProcessBuilder(shell.toString(), "--noprofile", 
"--norc", scriptFile.toString())
+                .directory(project.toFile())
+                .redirectErrorStream(true)
+                .redirectOutput(log.toFile());
+        var env = builder.environment();
+        // Noninteractive bash reads BASH_ENV even with --noprofile/--norc. 
Also discard inherited MSYS overrides.
+        for (var name : new String[] {
+            "BASH_ENV",
+            "ENV",
+            "MAVEN_OPTS",
+            "MAVEN_ARGS",
+            "MAVEN_CONFIG",
+            "MSYS2_ENV_CONV_EXCL",
+            "MSYS2_ARG_CONV_EXCL",
+            "MSYS_NO_PATHCONV",
+            "JAVA_TOOL_OPTIONS",
+            "JDK_JAVA_OPTIONS",
+            "_JAVA_OPTIONS"
+        }) {
+            env.remove(name);
+        }
+        env.put("PATH", shell.getParent().toString());
+        env.put("PATHEXT", pathExt);
+        env.put("MAVEN_SKIP_RC", "true");
+        env.put("IT_FAKE_PATH", fakeBin.toString());
+        env.put(
+                "IT_JAVA_HOME",
+                
Path.of(System.getProperty("java.home")).toAbsolutePath().toString());
+        env.put(
+                "IT_MAVEN_HOME",
+                
Path.of(System.getProperty("maven.home")).toAbsolutePath().toString());
+        env.put(
+                "IT_REPO",
+                Path.of(System.getProperty(
+                                "maven.test.repo.local",
+                                project.resolve("repository").toString()))
+                        .toAbsolutePath()
+                        .toString());
+        env.put(
+                "IT_USER_HOME",
+                Path.of(System.getProperty(
+                                "maven.test.user.home",
+                                project.resolve("user-home").toString()))
+                        .toAbsolutePath()
+                        .toString());
+        env.put(
+                "IT_SETTINGS",
+                Path.of(System.getProperty("maven.it.global-settings.dir", 
"target/test-classes"))
+                        .resolve("settings-remote.xml")
+                        .toAbsolutePath()
+                        .toString());
+
+        var process = builder.start();
+        try {
+            var ended = process.waitFor(2, TimeUnit.MINUTES);
+            if (!ended) {
+                // The launcher can still be waiting for Java: do not leave 
that child running on CI.
+                try (var descendants = process.descendants()) {
+                    descendants.forEach(ProcessHandle::destroyForcibly);
+                }
+                process.destroyForcibly();
+                process.waitFor(10, TimeUnit.SECONDS);
+            }
+            var output = Files.readString(log, StandardCharsets.UTF_8);
+            var diagnostic = shell + " (suffix=" + suffix + ", PATHEXT=" + 
pathExt + "), log: " + log + "\n" + output;
+            assertTrue(ended, "Maven did not end in time: " + diagnostic);
+            assertEquals(0, process.exitValue(), diagnostic);
+            assertTrue(output.contains("BUILD SUCCESS"), diagnostic);
+            var marker = project.resolve("target/profile.properties");
+            assertTrue(Files.isRegularFile(marker), "No profile marker: " + 
diagnostic);
+            var properties = new Properties();
+            try (var input = Files.newInputStream(marker)) {
+                properties.load(input);
+            }
+            assertEquals(
+                    active ? "active" : "inactive",
+                    
properties.getProperty("project.properties.executable.profile"),
+                    diagnostic);
+        } finally {
+            if (process.isAlive()) {
+                try (var descendants = process.descendants()) {
+                    descendants.forEach(ProcessHandle::destroyForcibly);
+                }
+                process.destroyForcibly();
+                process.waitFor(10, TimeUnit.SECONDS);
+            }
+            assertFalse(Files.exists(project.resolve("executed")), "Activation 
executed the fake tool; see " + log);
+        }
+    }
+}
diff --git 
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10115ProfileActivationByExecutableTest.java
 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10115ProfileActivationByExecutableTest.java
new file mode 100644
index 0000000000..5d5c7234c1
--- /dev/null
+++ 
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh10115ProfileActivationByExecutableTest.java
@@ -0,0 +1,170 @@
+/*
+ * 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.maven.it;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.PosixFilePermissions;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Verifies that executable() profile activation searches the forked Maven 
process's PATH without running the command.
+ */
+class MavenITgh10115ProfileActivationByExecutableTest extends 
AbstractMavenIntegrationTestCase {
+    private static final String COMMAND = "gh10115-profile-tool";
+    private static final String BIN = "fake bin with spaces";
+
+    @Test
+    void testMissingExecutable() throws Exception {
+        var project = createProject();
+        verifyActivation(project, false);
+    }
+
+    @Test
+    void testDirectoryIsNotExecutable() throws Exception {
+        var project = createProject();
+        Files.createDirectory(project.resolve(BIN).resolve(COMMAND));
+        verifyActivation(project, false);
+    }
+
+    @Test
+    @DisabledOnOs(OS.WINDOWS)
+    void testPosixExecutable() throws Exception {
+        var project = createProject();
+        createFakeExecutable(project, COMMAND, true);
+        verifyActivation(project, true);
+    }
+
+    @Test
+    @DisabledOnOs(OS.WINDOWS)
+    void testPosixNonExecutable() throws Exception {
+        var project = createProject();
+        createFakeExecutable(project, COMMAND, false);
+        verifyActivation(project, false);
+    }
+
+    @Test
+    @EnabledOnOs(OS.WINDOWS)
+    void testWindowsExeSuffix() throws Exception {
+        var project = createProject();
+        createFakeExecutable(project, COMMAND + ".EXE", true);
+        verifyActivation(project, true);
+    }
+
+    @Test
+    @EnabledOnOs(OS.WINDOWS)
+    void testWindowsCmdSuffix() throws Exception {
+        var project = createProject();
+        createFakeExecutable(project, COMMAND + ".CMD", true);
+        verifyActivation(project, true);
+    }
+
+    @Test
+    @EnabledOnOs(OS.WINDOWS)
+    void testWindowsCustomPathExtIsNotUsed() throws Exception {
+        var project = createProject();
+        createFakeExecutable(project, COMMAND + ".GH10115", true);
+        verifyActivation(project, false);
+    }
+
+    @Test
+    @EnabledOnOs(OS.WINDOWS)
+    void testWindowsCustomPathExtIsUsed() throws Exception {
+        var project = createProject();
+        createFakeExecutable(project, COMMAND + ".GH10115", true);
+        verifyActivation(project, true, ".EXE;.CMD;.GH10115");
+    }
+
+    private Path createProject() throws Exception {
+        var fixture = 
extractResources("gh-10115-profile-activation-by-executable");
+        // Resource extraction returns a shared directory. Never reuse its 
PATH entries or build output between cases.
+        var project = Files.createTempDirectory(fixture, getName() + "-");
+        Files.copy(fixture.resolve("pom.xml"), project.resolve("pom.xml"));
+        Files.createDirectory(project.resolve(BIN));
+        return project;
+    }
+
+    private void createFakeExecutable(Path project, String name, boolean 
executable) throws Exception {
+        var file = project.resolve(BIN).resolve(name);
+        // These are detection-only files, not real tools. An accidental 
invocation leaves evidence and fails.
+        if (File.separatorChar == '\\') {
+            Files.writeString(file, "@echo 
executed>\"%~dp0..\\executed\"\r\n@exit /b 97\r\n");
+        } else {
+            Files.writeString(file, "#!/bin/sh\n: > 
\"${0%/*}/../executed\"\nexit 97\n");
+            Files.setPosixFilePermissions(
+                    file, PosixFilePermissions.fromString(executable ? 
"rwxr-xr-x" : "rw-r--r--"));
+            assertEquals(executable, Files.isExecutable(file), "Fixture must 
have the requested execute permissions");
+        }
+    }
+
+    private void verifyActivation(Path project, boolean active) throws 
Exception {
+        verifyActivation(project, active, ".EXE;.CMD");
+    }
+
+    private void verifyActivation(Path project, boolean active, String 
pathExt) throws Exception {
+        var support = Files.createDirectory(project.resolve("launcher-tools"));
+        if (File.separatorChar == '\\') {
+            // mvn.cmd uses findstr for compact option parsing. Do not expose 
all of System32 on PATH.
+            // SystemRoot is optional in the environment, so never dereference 
it without a fallback.
+            var systemRoot = System.getenv("SystemRoot");
+            var findstr = Path.of(
+                    systemRoot == null || systemRoot.isBlank() ? "C:\\Windows" 
: systemRoot, "System32", "findstr.exe");
+            assertTrue(Files.isRegularFile(findstr), "Missing Maven launcher 
prerequisite: " + findstr);
+            Files.copy(findstr, support.resolve("findstr.exe"));
+        } else {
+            // The executor invokes bin/mvn, not java directly. Supply only 
its required external utilities.
+            // Resolve these from fixed OS locations, never from the inherited 
PATH.
+            for (var tool : new String[] {"uname", "dirname"}) {
+                var usrBin = Path.of("/usr/bin", tool);
+                var source = Files.isExecutable(usrBin) ? usrBin : 
Path.of("/bin", tool);
+                assertTrue(Files.isExecutable(source), "Missing Maven launcher 
prerequisite: " + source);
+                Files.createSymbolicLink(support.resolve(tool), source);
+            }
+        }
+        var path = project.resolve(BIN) + File.pathSeparator + support;
+        var verifier = newVerifier(project);
+        verifier.setForkJvm(true);
+        verifier.setAutoclean(false);
+        verifier.setEnvironmentVariable("JAVA_HOME", 
System.getProperty("java.home"));
+        verifier.setEnvironmentVariable("MAVEN_SKIP_RC", "true");
+        // Replace both spellings, including on case-sensitive hosts. Never 
append the inherited PATH.
+        verifier.setEnvironmentVariable("PATH", path);
+        verifier.setEnvironmentVariable("Path", path);
+        verifier.setEnvironmentVariable("PATHEXT", pathExt);
+        verifier.addCliArgument("validate");
+        try {
+            verifier.execute();
+            verifier.verifyErrorFreeLog();
+            var properties = 
verifier.loadProperties("target/profile.properties");
+            assertEquals(
+                    active ? "active" : "inactive", 
properties.getProperty("project.properties.executable.profile"));
+        } finally {
+            assertFalse(Files.exists(project.resolve("executed")), "Profile 
activation must not execute the fake tool");
+        }
+    }
+}
diff --git 
a/its/core-it-suite/src/test/resources/gh-10115-profile-activation-by-executable/pom.xml
 
b/its/core-it-suite/src/test/resources/gh-10115-profile-activation-by-executable/pom.xml
new file mode 100644
index 0000000000..c96b056306
--- /dev/null
+++ 
b/its/core-it-suite/src/test/resources/gh-10115-profile-activation-by-executable/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.1.0";>
+  <modelVersion>4.1.0</modelVersion>
+
+  <groupId>org.apache.maven.its.gh10115</groupId>
+  <artifactId>profile-activation-by-executable</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: GH-10115</name>
+  <description>Executable profile activation detects files on PATH without 
executing them.</description>
+
+  <properties>
+    <executable.profile>inactive</executable.profile>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-expression</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>eval</goal>
+            </goals>
+            <phase>validate</phase>
+            <configuration>
+              <outputFile>target/profile.properties</outputFile>
+              <expressions>
+                <expression>project/properties</expression>
+              </expressions>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>executable</id>
+      <activation>
+        <condition>executable('gh10115-profile-tool')</condition>
+      </activation>
+      <properties>
+        <executable.profile>active</executable.profile>
+      </properties>
+    </profile>
+  </profiles>
+</project>

Reply via email to