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

slachiewicz pushed a commit to branch fix-build
in repository https://gitbox.apache.org/repos/asf/maven-gpg-plugin.git


The following commit(s) were added to refs/heads/fix-build by this push:
     new b5a6bc0  Fix #322: Simplify path handling by using setFile() with 
MSYS_NO_PATHCONV
b5a6bc0 is described below

commit b5a6bc02a412531530d3f5571092ee177df29fb8
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Tue Jun 30 09:31:52 2026 +0200

    Fix #322: Simplify path handling by using setFile() with MSYS_NO_PATHCONV
    
    Instead of manually converting Windows paths to MinGW format, use the
    proper plexus-utils API: setFile().
    
    Combined with MSYS_NO_PATHCONV=1 environment variable (added earlier),
    this should properly handle Windows paths in MinGW environments without
    manual path manipulation.
    
    - Removed toMinGWPath() method
    - Changed all setValue(getAbsolutePath()) to setFile() for:
      - homeDir argument
      - signature output file
      - input file to sign
    
    This approach is cleaner, uses proper APIs, and avoids brittle path 
conversion logic.
---
 .../java/org/apache/maven/plugins/gpg/GpgSigner.java | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java 
b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
index 7e54e39..bc2acc3 100644
--- a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
+++ b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
@@ -50,20 +50,6 @@ public class GpgSigner extends AbstractGpgSigner {
         return keyname != null ? keyname : "default";
     }
 
-    /**
-     * Converts a Windows absolute path to MinGW path format for GPG on 
Windows.
-     * For example, converts "D:/a/b/c" to "/d/a/b/c".
-     * This prevents MSYS2/GPG from incorrectly prepending the current working 
directory.
-     */
-    private String toMinGWPath(String path) {
-        String forwardPath = path.replace('\\', '/');
-        if (Os.isFamily(Os.FAMILY_WINDOWS) && forwardPath.length() >= 2 && 
forwardPath.charAt(1) == ':') {
-            char driveLetter = Character.toLowerCase(forwardPath.charAt(0));
-            return "/" + driveLetter + forwardPath.substring(2);
-        }
-        return forwardPath;
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -100,7 +86,7 @@ public class GpgSigner extends AbstractGpgSigner {
 
         if (homeDir != null) {
             cmd.createArg().setValue("--homedir");
-            cmd.createArg().setValue(toMinGWPath(homeDir.getAbsolutePath()));
+            cmd.createArg().setFile(homeDir);
         }
 
         if (gpgVersion.isBefore(GpgVersion.parse("2.1"))) {
@@ -192,9 +178,9 @@ public class GpgSigner extends AbstractGpgSigner {
         }
 
         cmd.createArg().setValue("--output");
-        cmd.createArg().setValue(toMinGWPath(signature.getAbsolutePath()));
+        cmd.createArg().setFile(signature);
 
-        cmd.createArg().setValue(toMinGWPath(file.getAbsolutePath()));
+        cmd.createArg().setFile(file);
 
         // 
----------------------------------------------------------------------------
         // Execute the command line

Reply via email to