From 75d8ed56a05e7e886a61a92f076506b8ffba2bd1 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 15 Mar 2024 08:40:39 +0100 Subject: [PATCH] [MGPG-112] serverId def value was unintentionally dropped (#80) That caused that settings.xml could not deliver GPG passphrase as it was set up in setup-java. Plus, related IT was neutered and it did not do what it was supposed to do. This yields 3.2.1 release as 3.2.0 broke pw pickup from settings.xml --- https://issues.apache.org/jira/browse/MGPG-112 --- pom.xml | 4 +--- src/it/settings.xml | 8 ++++++++ .../invoker.properties | 18 ------------------ .../pom.xml | 4 +++- .../verify.groovy | 2 +- .../maven/plugins/gpg/AbstractGpgMojo.java | 6 +++--- .../apache/maven/plugins/gpg/GpgSigner.java | 2 ++ 7 files changed, 18 insertions(+), 26 deletions(-) delete mode 100644 src/it/sign-with-passphase-from-maven-settings/invoker.properties diff --git a/pom.xml b/pom.xml index 9aa88c6..b8216a1 100644 --- a/pom.xml +++ b/pom.xml @@ -274,9 +274,6 @@ under the License. clean install - - ${project.build.testOutputDirectory}/gnupg - @@ -299,6 +296,7 @@ under the License. gpg + ${project.build.testOutputDirectory}/gnupg diff --git a/src/it/settings.xml b/src/it/settings.xml index 98c2d3a..0c32550 100644 --- a/src/it/settings.xml +++ b/src/it/settings.xml @@ -23,4 +23,12 @@ under the License. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> + + + + gpg.passphrase-sign-with-passphase-from-maven-settings + TEST + + + diff --git a/src/it/sign-with-passphase-from-maven-settings/invoker.properties b/src/it/sign-with-passphase-from-maven-settings/invoker.properties deleted file mode 100644 index 1122205..0000000 --- a/src/it/sign-with-passphase-from-maven-settings/invoker.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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. - -invoker.environmentVariables.MAVEN_GPG_PASSPHRASE = TEST diff --git a/src/it/sign-with-passphase-from-maven-settings/pom.xml b/src/it/sign-with-passphase-from-maven-settings/pom.xml index 3259e0c..02bb5f7 100644 --- a/src/it/sign-with-passphase-from-maven-settings/pom.xml +++ b/src/it/sign-with-passphase-from-maven-settings/pom.xml @@ -22,7 +22,7 @@ under the License. 4.0.0 - org.apache.maven.its.gpg.nma + org.apache.maven.its.gpg.swpfmc test 1.0 jar @@ -48,6 +48,8 @@ under the License. @project.version@ + + gpg.passphrase-sign-with-passphase-from-maven-settings diff --git a/src/it/sign-with-passphase-from-maven-settings/verify.groovy b/src/it/sign-with-passphase-from-maven-settings/verify.groovy index 49b5553..a491aa7 100644 --- a/src/it/sign-with-passphase-from-maven-settings/verify.groovy +++ b/src/it/sign-with-passphase-from-maven-settings/verify.groovy @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -var artifactDir = new File(localRepositoryPath, "org/apache/maven/its/gpg/nma/test/1.0") +var artifactDir = new File(localRepositoryPath, "org/apache/maven/its/gpg/swpfmc/test/1.0") var expectedFiles = [ "test-1.0.pom", diff --git a/src/main/java/org/apache/maven/plugins/gpg/AbstractGpgMojo.java b/src/main/java/org/apache/maven/plugins/gpg/AbstractGpgMojo.java index 52c61b2..9e159d0 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/AbstractGpgMojo.java +++ b/src/main/java/org/apache/maven/plugins/gpg/AbstractGpgMojo.java @@ -121,7 +121,7 @@ public abstract class AbstractGpgMojo extends AbstractMojo { * variables instead. **/ @Deprecated - @Parameter(property = "gpg.passphrase") + @Parameter(property = GPG_PASSPHRASE) private String passphrase; /** @@ -134,7 +134,7 @@ public abstract class AbstractGpgMojo extends AbstractMojo { * variables instead. **/ @Deprecated - @Parameter(property = "gpg.passphraseServerId") + @Parameter(property = "gpg.passphraseServerId", defaultValue = GPG_PASSPHRASE) private String passphraseServerId; /** @@ -392,7 +392,7 @@ private boolean isNotBlank(String string) { @Deprecated private String loadGpgPassphrase() throws MojoFailureException { - if (isNotBlank(passphrase)) { + if (isNotBlank(passphraseServerId)) { Server server = settings.getServer(passphraseServerId); if (server != null) { if (isNotBlank(server.getPassphrase())) { 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 673e50d..02158ee 100644 --- a/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java +++ b/src/main/java/org/apache/maven/plugins/gpg/GpgSigner.java @@ -178,6 +178,8 @@ protected void generateSignatureForFile(File file, File signature) throws MojoEx // Execute the command line // ---------------------------------------------------------------------------- + getLog().debug("CMD: " + cmd); + try { int exitCode = CommandLineUtils.executeCommandLine(cmd, in, new DefaultConsumer(), new DefaultConsumer());