Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-7754] Improvement and extension of plugin validation #1079

Conversation

cstamas
Copy link
Member

@cstamas cstamas commented Apr 3, 2023

This is general rework of current Maven 3.9.x line how it handles plugin and mojo validations.

Changes:

  • added plugin validations for dependencies
  • introduced pluginValidationManager that gathers violations
  • manager creates a report at build end, with dense and non repeating data
  • this is in spirit to lessen already too verbose logging, as current solution would report violations as many times plugin is used in reactor, and that can be many (ie. a plugin from parent for each module)

Example report of Maven 3.9.x build: https://gist.github.com/cstamas/b62fdcd53eaf316123cf183f5a24e6a5


https://issues.apache.org/jira/browse/MNG-7754

@cstamas cstamas self-assigned this Apr 3, 2023
@cstamas cstamas changed the title [MNG-7754] Improve Mojo parameter deprecation message [MNG-7754] Improvement and extension of plugin validation handling Apr 4, 2023
@cstamas cstamas changed the title [MNG-7754] Improvement and extension of plugin validation handling [MNG-7754] Improvement and extension of plugin validation Apr 4, 2023
cstamas added a commit to cstamas/maven-integration-testing that referenced this pull request Apr 4, 2023
Fixed ITs to not fail:
- assert only for content, neglect and possible indentation
- do not assert what is NOT warn logged, as later we may log more (IT would be not future proof)

Tested with 3.9.1 and 3,9,2-SNAPSHOT w/ apache/maven#1079
Both passes OK
@cstamas
Copy link
Member Author

cstamas commented Apr 4, 2023

IT fix apache/maven-integration-testing#256
Tested with 3.9.1 and this PR, both pass OK

Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

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

Looking at the output:

[WARNING]    * 70 : 15, org.apache.maven:maven-settings-builder:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-settings-builder/pom.xml
[WARNING]    * 131 : 15, org.apache.maven:maven-resolver-provider:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-resolver-provider/pom.xml
[WARNING]    * 192 : 15, org.apache.maven:maven-core:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-core/pom.xml

I don't understand how to read those numbers and to what they relate.


@Override
public void validate(MavenSession mavenSession, MojoDescriptor mojoDescriptor) {
if (mojoDescriptor.getPluginDescriptor() != null
Copy link
Member

Choose a reason for hiding this comment

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

Can they be null?! Weird

if (mavenVersions.size() > 1) {
pluginValidationManager.reportPluginValidationIssue(
mavenSession, mojoDescriptor, "Plugin mixes multiple Maven versions: " + mavenVersions);
}
Copy link
Member

Choose a reason for hiding this comment

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

How to understand this message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unsure how to put it in words, but the point is that "among plugin dependencies there are maven artifacts that has different versions" -- kinda like "dep convergence" but for maven? There are some shared stuff (maybe older filtering) that caused this, especially as they pulled in maven-project, artifact that is gone from maven 3, so even depMgt could not "align" it as it was maven2 artifact.

Copy link
Member

Choose a reason for hiding this comment

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

Now I see, from the message it is hard to derive that.

Copy link
Member

@slawekjaranowski slawekjaranowski left a comment

Choose a reason for hiding this comment

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

I would like to put sections:

  • Declared at location(s)
  • Used in module(s)

as optional - default disabled - in projects with hundred modules such message will make more mess than benefit

maybe we can have a option
maven.plugin.validation with values:

  • dafault
  • verbose with location and modules
  • false - disbaled at all

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

Applied PR comments and proposals

If user set anything, fail if value is junk
Report validation issues (as one liner warning) even if disabled
Do not fail just warn when wrong value for property set
@michael-o
Copy link
Member

I still have a problem to read that this output:

Don't bother, it comes only when you set 'verbose' but that means you have bigger problems as well 😆

Seriously: any proposal how to improve it?

I don't even know what those numbers mean, can you point me to the source where it comes from?

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

They point to POM sources:
70 : 15, org.apache.maven:maven-settings-builder:3.9.2-SNAPSHOT -> https://github.com/apache/maven/blob/maven-3.9.x/maven-settings-builder/pom.xml#L70
131 : 15, org.apache.maven:maven-resolver-provider:3.9.2-SNAPSHOT -> https://github.com/apache/maven/blob/maven-3.9.x/maven-resolver-provider/pom.xml#L131
192 : 15, org.apache.maven:maven-core:3.9.2-SNAPSHOT -> https://github.com/apache/maven/blob/maven-3.9.x/maven-core/pom.xml#L192

@gnodet
Copy link
Contributor

gnodet commented Apr 5, 2023

What about:

[WARNING]    * org.apache.maven:maven-settings-builder:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-settings-builder/pom.xml, line 70, column 15
[WARNING]    * org.apache.maven:maven-resolver-provider:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-resolver-provider/pom.xml, line 131, column 15
[WARNING]    * org.apache.maven:maven-core:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-core/pom.xml, line 192, column 15

@michael-o
Copy link
Member

What about:

[WARNING]    * org.apache.maven:maven-settings-builder:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-settings-builder/pom.xml, line 70, column 15
[WARNING]    * org.apache.maven:maven-resolver-provider:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-resolver-provider/pom.xml, line 131, column 15
[WARNING]    * org.apache.maven:maven-core:3.9.2-SNAPSHOT /home/cstamas/Worx/apache-maven/maven/maven-core/pom.xml, line 192, column 15

this is much better, we can leverage an improvement (#756) from @hboutemy recently:

[WARNING] * org.apache.maven:maven-core:3.9.2-SNAPSHOT from /home/cstamas/Worx/apache-maven/maven/maven-core/pom.xml, line 192, column 15

[WARNING] * org.apache.maven:maven-core:3.9.2-SNAPSHOT from maven-core/pom.xml, line 192, column 15

which might even shorten the output. The rest is from org.apache.maven.building.DefaultProblem.getLocation()

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

The improvement is already in, in the "Used in module(s)" section, see https://gist.github.com/cstamas/b62fdcd53eaf316123cf183f5a24e6a5#file-gistfile1-txt-L39

But here I have no idea how to reformat location... any example?

@michael-o
Copy link
Member

michael-o commented Apr 5, 2023

The improvement is already in, in the "Used in module(s)" section, see https://gist.github.com/cstamas/b62fdcd53eaf316123cf183f5a24e6a5#file-gistfile1-txt-L39

But here I have no idea how to reformat location... any example?

Right, but not here: https://gist.github.com/cstamas/b62fdcd53eaf316123cf183f5a24e6a5#file-gistfile1-txt-L71-L75

As a user is just causes confusion, not clarification.

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

Updated gist with new output. Removed prj.name as well to consistently use g:a:v (whether in build module or external artifact), and this also smooth out the output. Also, showing only line number, IMHO no need for column

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

Updated gist once more: since last, removed "from" repeated string, only path alone is in braces. If within TLP, is relative, otherwise is abs (ie. from local repo).

@gnodet
Copy link
Contributor

gnodet commented Apr 5, 2023

Updated gist once more: since last, removed "from" repeated string, only path alone is in braces. If within TLP, is relative, otherwise is abs (ie. from local repo).

I wonder if the class: should be removed too... Not sure it bring much.

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

Agreed, and removed

stringBuilder.append(inputLocation.getSource().getModelId());
String location = inputLocation.getSource().getLocation();
if (location != null) {
if (location.contains("://")) {
Copy link
Member

Choose a reason for hiding this comment

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

You assume that this can be a URL?

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

Interesting, invoked mvn help:help and mvn clean (was just wondering what happens), and BOTH produce SAME output:

[WARNING] 
[WARNING] Plugin validation issues were detected in 1 plugin(s)
[WARNING] 
[WARNING] Plugin org.apache.maven.plugins:maven-site-plugin:3.12.1
[WARNING]   Plugin issue(s):
[WARNING]    * Plugin depends on the deprecated Maven 2.x compatibility layer, which may not be supported in Maven 4.x
[WARNING] 
[WARNING] 
[WARNING] To fix these issues, please upgrade above listed plugins, or, notify their maintainers about reported issues.
[WARNING] 
[WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [DISABLED, ENABLED, VERBOSE]
[WARNING] 
➜  

How does site plugin come in picture for ANY of these?

@michael-o
Copy link
Member

Interesting, invoked mvn help:help and mvn clean (was just wondering what happens), and BOTH produce SAME output:

[WARNING] 
[WARNING] Plugin validation issues were detected in 1 plugin(s)
[WARNING] 
[WARNING] Plugin org.apache.maven.plugins:maven-site-plugin:3.12.1
[WARNING]   Plugin issue(s):
[WARNING]    * Plugin depends on the deprecated Maven 2.x compatibility layer, which may not be supported in Maven 4.x
[WARNING] 
[WARNING] 
[WARNING] To fix these issues, please upgrade above listed plugins, or, notify their maintainers about reported issues.
[WARNING] 
[WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [DISABLED, ENABLED, VERBOSE]
[WARNING] 
➜  

How does site plugin come in picture for ANY of these?

Lifecycle binding?

@cstamas
Copy link
Member Author

cstamas commented Apr 5, 2023

Lifecycle binding?

Huh? for help:help which lifecycle you mean specifically? Also, for clean lifecycle, where is site? https://github.com/apache/maven/blob/maven-3.9.x/maven-core/src/main/resources/META-INF/plexus/components.xml#L67

BTW, the message means site plugin is LOADED up RESOLVED. Why?

@michael-o
Copy link
Member

Lifecycle binding?

Huh? for help:help which lifecycle you mean specifically? Also, for clean lifecycle, where is site? https://github.com/apache/maven/blob/maven-3.9.x/maven-core/src/main/resources/META-INF/plexus/components.xml#L67

BTW, the message means site plugin is LOADED up RESOLVED. Why?

Eager plugin scanning in core?`Remove maven-site-plugin from local repo and try again. This might prove my theory.

cstamas and others added 2 commits April 12, 2023 11:11
…ecatedCoreExpressionValidator.java

Co-authored-by: Konrad Windszus <konrad_w@gmx.de>
@cstamas cstamas merged commit 36a4e9f into apache:maven-3.9.x Apr 12, 2023
@cstamas cstamas deleted the maven-3.9.x-MNG-7754-deprecation-message-rephrase branch April 12, 2023 09:42
cstamas added a commit to cstamas/maven that referenced this pull request Apr 12, 2023
This is general rework of current Maven 3.9.x line how it handles plugin and mojo validations.

Changes:
* added plugin validations for dependencies
* introduced pluginValidationManager that gathers violations
* manager creates a report at build end, with dense and non repeating data
* this is in spirit to lessen already too verbose logging, as current solution would report violations as many times plugin is used in reactor, and that can be many (ie. a plugin from parent for each module)

Example report of Maven 3.9.x build: https://gist.github.com/cstamas/b62fdcd53eaf316123cf183f5a24e6a5

---

https://issues.apache.org/jira/browse/MNG-7754
cstamas added a commit that referenced this pull request Apr 12, 2023
This is general rework of current Maven 3.9.x line how it handles plugin and mojo validations.

Changes:
* added plugin validations for dependencies
* introduced pluginValidationManager that gathers violations
* manager creates a report at build end, with dense and non repeating data
* this is in spirit to lessen already too verbose logging, as current solution would report violations as many times plugin is used in reactor, and that can be many (ie. a plugin from parent for each module)

Example report of Maven 3.9.x build: https://gist.github.com/cstamas/b62fdcd53eaf316123cf183f5a24e6a5

---

https://issues.apache.org/jira/browse/MNG-7754
@gnodet gnodet mentioned this pull request May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants