GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [MGPG-125] Fix "bestPractices" by cstamas · Pull Request #95 · apache/maven-gpg-plugin

Conversation

@cstamas

@cstamas cstamas commented Apr 11, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

As currently due defaulted values it would always fail, unless user explicitly re-configures plugin. So, do not set "default value" on mojo level, instead handle it programmatically, when bestPractices is not set. Added ITs for "bestPractices", one for success and one for failure.


https://issues.apache.org/jira/browse/MGPG-125

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cstamas
[MGPG-125] Fix "bestPractices"
606455d
As currently due defaulted values it would always fail, unless
user explicitly re-configures plugin.

---

https://issues.apache.org/jira/browse/MGPG-125
@cstamas
cstamas requested review from bmarwell and slawekjaranowski April 11, 2024 13:08
@cstamas cstamas self-assigned this Apr 11, 2024
@cstamas
Use same method for check
b0aa01b
bmarwell
bmarwell reviewed Apr 11, 2024
View reviewed changes

@bmarwell bmarwell left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly a little groovy and nesting readability thoughts.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/it/sign-release-best-practices-fail/verify.groovy Outdated
Comment on lines +21 to +24
import org.codehaus.plexus.util.FileUtils

var buildLog = new File(basedir, "build.log")
var logContent = FileUtils.fileRead(buildLog)

@bmarwell bmarwell Apr 11, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Groovy can do that without plexus utils:

String logContent = new File( basedir, "build.log").text

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/it/sign-release-best-practices-fail/verify.groovy Outdated
Comment on lines +26 to +29
// assert that bestPractice+worstPractice => MojoFailure
if (!logContent.contains("MojoFailureException: Do not store passphrase in any file")) {
throw new Exception("Maven build did not fail in consequence of bestPractices+worstPractices")
}

@bmarwell bmarwell Apr 11, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Groovy's native assert is quite suitable here:

assert logContent.contains( "..." )

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/plugins/gpg/AbstractGpgMojo.java
Comment on lines +303 to +310
if (bestPractices) {
if (isNotBlank(passphrase) || isNotBlank(passphraseServerId)) {
// Stop propagating worst practices: passphrase MUST NOT be in any file on disk
throw new MojoFailureException(
"Do not store passphrase in any file (disk or SCM repository), rely on GnuPG agent or provide passphrase in "
+ passphraseEnvName + " environment variable.");
}
} else {

@bmarwell bmarwell Apr 11, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As best practices will probably be extended in the future, why not just refactor out a method here?

Suggested change
if (bestPractices) {
if (isNotBlank(passphrase) || isNotBlank(passphraseServerId)) {
// Stop propagating worst practices: passphrase MUST NOT be in any file on disk
throw new MojoFailureException(
"Do not store passphrase in any file (disk or SCM repository), rely on GnuPG agent or provide passphrase in "
+ passphraseEnvName + " environment variable.");
}
} else {
if (bestPractices) {
checkForBestPractices();
} else {

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/plugins/gpg/AbstractGpgMojo.java
Comment on lines +310 to +314
} else {
if (!isNotBlank(passphraseServerId)) {
// default it programmatically: this is needed to handle different cases re bestPractices
passphraseServerId = GPG_PASSPHRASE;
}

@bmarwell bmarwell Apr 11, 2024

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is a default case inside an else-if nesting. However, as the isolated if(bestPractices) improves readability, I'd say: keep it for now.

One solution would be to refactor out a method like setDefaults(), but probably not worth it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cstamas cstamas Apr 11, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields are deprecated and are meant to be removed.. so IMO that would be overkill. Soon, when "bestPractices" can be true only (removed), all these will be gone.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cstamas

cstamas commented Apr 11, 2024

Copy link
Copy Markdown
Member Author

Btw, this whole PR (with all "non groovy-ness") was copy pasted from other ITs... So maybe we need a "sweeping change" instead where we rewrite the ITs in this plugin to "groovy-like" constructs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

slawekjaranowski
slawekjaranowski reviewed Apr 12, 2024
View reviewed changes
Comment thread src/it/sign-release-best-practices-fail/pom.xml Outdated
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>

@slawekjaranowski slawekjaranowski Apr 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?
we can use @version.maven-compiler-plugin@ properties for plugins versions are defined in parent

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
slawekjaranowski
slawekjaranowski reviewed Apr 12, 2024
View reviewed changes
Comment thread src/it/sign-release-best-practices-fail/pom.xml Outdated
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.2</version>

@slawekjaranowski slawekjaranowski Apr 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
slawekjaranowski
slawekjaranowski reviewed Apr 12, 2024
View reviewed changes
Comment thread src/it/sign-release-best-practices/verify.groovy Outdated

println "Checking for existence of $file"

if (!file.isFile()) {

@slawekjaranowski slawekjaranowski Apr 12, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert file.isFile()

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cstamas
PR comments
ae95dc1
@cstamas
cstamas requested review from bmarwell and slawekjaranowski April 12, 2024 15:28
cstamas added 2 commits April 12, 2024 17:30
@cstamas
PR comments
297f137
@cstamas
Strange, locally this is not needed?
c592cd9
@cstamas

cstamas commented Apr 12, 2024

Copy link
Copy Markdown
Member Author

Updated PR with comments, but now the new IT is considerably slower (?) and also locally did not, but on CI fails (I guess the force sources creation is needed as there are actually no sources...) @slawekjaranowski ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski

slawekjaranowski commented Apr 12, 2024

Copy link
Copy Markdown
Member

but now the new IT is considerably slower ...

do you have any number to compare?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

slawekjaranowski
slawekjaranowski approved these changes Apr 12, 2024
View reviewed changes
@cstamas

cstamas commented Apr 12, 2024

Copy link
Copy Markdown
Member Author

For last build this PR:

[INFO] Building: sign-release-best-practices/pom.xml
[INFO] run post-build script verify.groovy
[INFO]           sign-release-best-practices/pom.xml .............. SUCCESS (4.002 s)

2nd build/commit:

[INFO] Building: sign-release-best-practices/pom.xml
[INFO] run post-build script verify.groovy
[INFO]           sign-release-best-practices/pom.xml .............. SUCCESS (3.877 s)

Hm, minimal... unsure what I "feel" locally. Maybe that these two ITs use new plugins (hence downoads them) while all the rest use old/ancient plugins but some version?

slawekjaranowski reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski

slawekjaranowski commented Apr 12, 2024

Copy link
Copy Markdown
Member

It can be a time needed for downloading new plugins version into tarted/local-repo
Too small difference to more investigating

build with mvn clean ...

gpg
[INFO]           sign-release-best-practices/pom.xml .............. SUCCESS (8.135 s)

bc
[INFO]           sign-release-best-practices/pom.xml .............. SUCCESS (2.189 s)

next without clean

gpg
[INFO]           sign-release-best-practices/pom.xml .............. SUCCESS (2.653 s)

bc
[INFO]           sign-release-best-practices/pom.xml .............. SUCCESS (2.237 s)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cstamas
cstamas merged commit 893aedc into apache:master Apr 13, 2024
@cstamas
cstamas deleted the MGPG-125 branch April 13, 2024 17:02
@v-aparnajyothi-y v-aparnajyothi-y mentioned this pull request Sep 6, 2024
GPG-Signing of maven artifacts fails on Windows runners with actions/setup-java@v4 and maven-gpg-plugin version range [3.2.0, 3.2.7) actions/setup-java#629
Closed
2 of 5 tasks
@jira-importer

jira-importer commented Jun 14, 2025

Copy link
Copy Markdown

Resolve #257

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

1 similar comment
@jira-importer

jira-importer commented Jun 14, 2025

Copy link
Copy Markdown

Resolve #257

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@slawekjaranowski slawekjaranowski slawekjaranowski approved these changes
@bmarwell bmarwell Awaiting requested review from bmarwell

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@cstamas cstamas

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@cstamas @slawekjaranowski @jira-importer @bmarwell
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.