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

commit 21209a30662b8ea96cce67afe28616b7bd3587d7
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Mon Jun 29 23:47:36 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.
    
    Fix #322: Convert Windows drive paths to MinGW format for GPG
    
    When GPG receives a Windows path with drive letter (e.g., D:/path), it 
incorrectly treats it as a relative path and prepends the current working 
directory. This causes errors like:
    
      gpg: keyblock resource '/d/a/b/c/D:/a/b/c/pubring.kbx': No such file or 
directory
    
    The fix introduces toMinGWPath() which converts Windows drive paths to 
MinGW format:
      - D:/a/b/c → /d/a/b/c
    
    Applied to homedir, output, and input file arguments. Combined with 
existing MSYS_NO_PATHCONV=1, this prevents path conversion errors on Windows.
    
    Fix #322: Use forward slashes for GPG file paths on Windows
    
    GPG in Gpg4win 5.x uses a Cygwin runtime that does not recognize Windows
    backslash paths as absolute. Paths like D:\a\...\gnupg are treated as
    relative (appended to CWD) because backslash is not a path separator in
    POSIX/Cygwin context.
    
    Replace setFile() calls with getValue(path.replace('\\', '/')) for all
    file paths passed to GPG (--homedir, --output, input file), so GPG
    receives D:/a/.../gnupg which Cygwin correctly interprets as absolute.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
    
    Fix #322: Restore pinentry-non-existent alongside allow-loopback-pinentry
    
    The allow-loopback-pinentry enables --pinentry-mode loopback for automated
    signing, but the pinentry-program pinentry-non-existent must be kept to
    ensure interactive signing (without passphrase) still fails as expected by
    GpgSignAttachedMojoIT.interactiveWithoutPassphrase.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
    
    Fix #322: Update test GPG keyring for GnuPG 2.4.x compatibility
    
    Gpg4win upgraded from 4.x to 5.x in Chocolatey, bringing GnuPG 2.4.9.
    GnuPG 2.4.x on Windows does not auto-migrate the old secring.gpg format.
    
    Add modern format key storage (private-keys-v1.d/ and pubring.kbx) to the
    test gnupg directory so GnuPG 2.1+ can find the test signing key without
    needing auto-migration from the legacy secring.gpg format.
    
    Also replace pinentry-program pinentry-non-existent with 
allow-loopback-pinentry
    in gpg-agent.conf, which properly supports --pinentry-mode loopback in GPG 
2.1+.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
    
    Fix #322: Prevent MinGW/MSYS path conversion in Windows builds
    
    Add MSYS_NO_PATHCONV=1 environment variable to prevent MinGW/MSYS
    environments (like GitHub Actions Windows runners) from converting
    Windows paths with drive letters to relative paths.
    
    This resolves the issue where paths like D:\a\project\gnupg were
    being mangled to /current/working/dir/D:\a\project\gnupg, causing
    GPG to fail finding key files.
---
 .../org/apache/maven/plugins/gpg/GpgSigner.java    |   2 ++
 src/test/resources/gnupg/.gpg-v21-migrated         |   0
 src/test/resources/gnupg/gpg-agent.conf            |   3 ++
 .../37E162403CBF3E1B55A281928F405CCA9217EF48.key   |  18 ++++++++++
 .../AA2B6F748C5149803448BB3CA083D18BC27295CB.key   |  37 +++++++++++++++++++++
 src/test/resources/gnupg/pubring.kbx               | Bin 0 -> 1399 bytes
 src/test/resources/gnupg/trustdb.gpg               | Bin 1280 -> 1280 bytes
 7 files changed, 60 insertions(+)

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 d63bd5f..bc2acc3 100644
--- a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
+++ b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java
@@ -61,6 +61,8 @@ public class GpgSigner extends AbstractGpgSigner {
 
         Commandline cmd = new Commandline();
 
+        cmd.addEnvironment("MSYS_NO_PATHCONV", "1");
+
         if (executable != null && !executable.isEmpty()) {
             cmd.setExecutable(executable);
         } else {
diff --git a/src/test/resources/gnupg/.gpg-v21-migrated 
b/src/test/resources/gnupg/.gpg-v21-migrated
new file mode 100644
index 0000000..e69de29
diff --git a/src/test/resources/gnupg/gpg-agent.conf 
b/src/test/resources/gnupg/gpg-agent.conf
index 00efc6f..b49d679 100644
--- a/src/test/resources/gnupg/gpg-agent.conf
+++ b/src/test/resources/gnupg/gpg-agent.conf
@@ -1,5 +1,8 @@
 # Prevent gpg-agent from caching the passphrase / unlocked key between 
integration tests
 ignore-cache-for-signing
 
+# Allow loopback pinentry mode required for --pinentry-mode loopback (GPG 2.1+)
+allow-loopback-pinentry
+
 # Prevent pinentry input prompts from blocking integration tests
 pinentry-program pinentry-non-existent
diff --git 
a/src/test/resources/gnupg/private-keys-v1.d/37E162403CBF3E1B55A281928F405CCA9217EF48.key
 
b/src/test/resources/gnupg/private-keys-v1.d/37E162403CBF3E1B55A281928F405CCA9217EF48.key
new file mode 100644
index 0000000..39a025a
--- /dev/null
+++ 
b/src/test/resources/gnupg/private-keys-v1.d/37E162403CBF3E1B55A281928F405CCA9217EF48.key
@@ -0,0 +1,18 @@
+Created: 20090902T164353
+Key: (protected-private-key (dsa (p #00E045ED473002752DDC675607D78A3613
+ B654817BB818A394AA62FCEF8B6EB1518B20385F7A378C579DFF9A34A2F80D9FA89CFA
+ A947549D36EE0373BF2F646AD2CF2023AE92EEC4E0C8AF9AFFC4298ECD1AF333C9D41A
+ 43FC2954AF70AF55E5D1EBC19647F8DDF8D01A6D88CC13248AEFB94380AF31C439CD34
+ 061D295E8C129B#)(q #00C0DEF0BBFBAF0B6106A538211D5FA1B7554CE777#)(g
+  #00B997CA876C610B0875214F875B252B5E06C28F2C8A96A0EEB872A5E93738F5F25B
+ 551FCAC8955D587475E59B6E2152C7F8B6C96AB502E9933CF7D347244658020501E455
+ E959E28A5E2E7EAD5A527DB2798A46A3F7154FE0F24183F5396EBFFBF9808DB6C4B596
+ AE41E5048D56B78F84AAC91D74B12E3279B27E72D3D005B7BF#)(y
+  #6FE5B4E397FBBD4DB88899B337E0AD7DB4121EDE34D0B7F57A4E3D6667C3FFB2C55A
+ EC11206A9A77FC163AE15E3C4A4871BA61231DCCB5C1CDE78CB31BF176EFF63B363BA6
+ E91BCE0204FDC837D8993B3EC0361C41BB01B92C9376D1B11C42C13780234BC7C4B3D8
+ 0E19FFCB197C9CEAE4D7469A25F65F42F711F17EA533252A#)(protected
+  openpgp-s2k3-ocb-aes ((sha1 #D25D73C42DCC3F19#
+  "56393728")#3514A7204666803A3C1406EF#)#ADC5A6792BEB239184752E931A2A51
+ 1C7DDF6088F19CC0D0B6BE711C603529FFB8076A70D07A150128FF4ECC601848A4FE#)
+ (protected-at "20260629T223351")))
diff --git 
a/src/test/resources/gnupg/private-keys-v1.d/AA2B6F748C5149803448BB3CA083D18BC27295CB.key
 
b/src/test/resources/gnupg/private-keys-v1.d/AA2B6F748C5149803448BB3CA083D18BC27295CB.key
new file mode 100644
index 0000000..bd23a76
--- /dev/null
+++ 
b/src/test/resources/gnupg/private-keys-v1.d/AA2B6F748C5149803448BB3CA083D18BC27295CB.key
@@ -0,0 +1,37 @@
+Created: 20090902T164353
+Key: (protected-private-key (elg (p #008A470AE8D9F9CF013B7311CA6CBEDD23
+ 5CC17B5A041C60551879DE4367AADAEDB569E723B26660ECC079614815E361680B069B
+ 39144CDAC25CB999B21CED6879FA2CD4B43F0B8B251671188202FA01385F49D072971E
+ 19D9C643345CAE81AD2465011AFB1EC1294CEA2C1543E81EC317C62C707765B3995E94
+ DC0FB870E9E3AE7643E5850984A53FE49C2E3FE651669CA2C91D50DAA75075A383CB9C
+ EF33CE2A8B61AE39119D616B39865915E2EAFC8A1BBBCC4AD00FDB015CF865CC5A9150
+ CFF62F9EF3DB05200CBA0D805CC2412669D51B5BD1566F223857674BEAB89F1428D595
+ A6E873963EEA39D3451F0100EA9454CBF7EABA4DDFD6F828D71E5266FD17#)(g
+  #05#)(y #6ED2EF8108E247D34EFAD93AF5842973BB33E4410A5A580992A9B0DF8FB2
+ DBFF428A9417CEA2B6F2D467652F3D57AAC6E4C336E80E86FB85BB80239615EA205811
+ 55BCC18238F61FA303570F1438F691BD6D4F8450AE9BDF3FB1809F5FC674A1C31AEA53
+ AF66682A053A8846FCEABBB981C19B3CF22DC7BAE53C330F1846C2BC5B6E3C898DA2C7
+ 10321D4538D1EDFBC60F2414D854916BB056A0FA9E495EC65645E06C9C4479CE7847A0
+ 7F0F4E06401A174C5A72AC86A11216B34BAE0CFD2691A0B89D532FEB2E4C6F423EE6C2
+ 9EF5E9B0C1974CC511612A26C1F403E255E18B0C770D304BD4B5E915B4EA88D05BFE36
+ A2279B13686BB04E9DBEB69A4F889E3F#)(protected openpgp-native
+  (openpgp-private-key (version "4")(algo ELG)(skey _
+  #008A470AE8D9F9CF013B7311CA6CBEDD235CC17B5A041C60551879DE4367AADAEDB5
+ 69E723B26660ECC079614815E361680B069B39144CDAC25CB999B21CED6879FA2CD4B4
+ 3F0B8B251671188202FA01385F49D072971E19D9C643345CAE81AD2465011AFB1EC129
+ 4CEA2C1543E81EC317C62C707765B3995E94DC0FB870E9E3AE7643E5850984A53FE49C
+ 2E3FE651669CA2C91D50DAA75075A383CB9CEF33CE2A8B61AE39119D616B39865915E2
+ EAFC8A1BBBCC4AD00FDB015CF865CC5A9150CFF62F9EF3DB05200CBA0D805CC2412669
+ D51B5BD1566F223857674BEAB89F1428D595A6E873963EEA39D3451F0100EA9454CBF7
+ EABA4DDFD6F828D71E5266FD17# _ #05# _ #6ED2EF8108E247D34EFAD93AF5842973
+ BB33E4410A5A580992A9B0DF8FB2DBFF428A9417CEA2B6F2D467652F3D57AAC6E4C336
+ E80E86FB85BB80239615EA20581155BCC18238F61FA303570F1438F691BD6D4F8450AE
+ 9BDF3FB1809F5FC674A1C31AEA53AF66682A053A8846FCEABBB981C19B3CF22DC7BAE5
+ 3C330F1846C2BC5B6E3C898DA2C710321D4538D1EDFBC60F2414D854916BB056A0FA9E
+ 495EC65645E06C9C4479CE7847A07F0F4E06401A174C5A72AC86A11216B34BAE0CFD26
+ 91A0B89D532FEB2E4C6F423EE6C29EF5E9B0C1974CC511612A26C1F403E255E18B0C77
+ 0D304BD4B5E915B4EA88D05BFE36A2279B13686BB04E9DBEB69A4F889E3F# e
+  #5DEA161D25C449749015F2123B6A2E1FE8CCBB8A10B6F56A1706B08DD946A2CE7A36
+ 28206DEE6E21512CCB5A14A66AE7715B8A0FCC627032EF54C7BFA6E0609F55#)(csum
+  "0")(protection sha1 AES #4522BD1DFB843F0E403E242090C54E71# "3" SHA1
+  #18B651F8A3FF3035# "255")))))
diff --git a/src/test/resources/gnupg/pubring.kbx 
b/src/test/resources/gnupg/pubring.kbx
new file mode 100644
index 0000000..0edf2a1
Binary files /dev/null and b/src/test/resources/gnupg/pubring.kbx differ
diff --git a/src/test/resources/gnupg/trustdb.gpg 
b/src/test/resources/gnupg/trustdb.gpg
index 40a38f5..d22b5ec 100644
Binary files a/src/test/resources/gnupg/trustdb.gpg and 
b/src/test/resources/gnupg/trustdb.gpg differ

Reply via email to