GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [MGPG-125] Fix "bestPractices" by cstamas · Pull Request #95 · apache/maven-gpg-plugin Conversation
|
| import org.codehaus.plexus.util.FileUtils | ||
|
|
||
| var buildLog = new File(basedir, "build.log") | ||
| var logContent = FileUtils.fileRead(buildLog) |
There was a problem 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.
There was an error while loading. Please reload this page.
| // 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") | ||
| } |
There was a problem 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.
There was an error while loading. Please reload this page.
| 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 { |
There was a problem 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?
| 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.
There was an error while loading. Please reload this page.
| } else { | ||
| if (!isNotBlank(passphraseServerId)) { | ||
| // default it programmatically: this is needed to handle different cases re bestPractices | ||
| passphraseServerId = GPG_PASSPHRASE; | ||
| } |
There was a problem 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.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>2.0.2</version> |
There was a problem 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.
There was an error while loading. Please reload this page.
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-install-plugin</artifactId> | ||
| <version>2.2</version> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
😄
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| println "Checking for existence of $file" | ||
|
|
||
| if (!file.isFile()) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
assert file.isFile()
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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 ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
do you have any number to compare? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
For last build this PR: 2nd build/commit: 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? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It can be a time needed for downloading new plugins version into tarted/local-repo build with next without |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Resolve #257 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Resolve #257 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.