-
Notifications
You must be signed in to change notification settings - Fork 56
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
[MPLUGIN-441] Support for the new maven4 api #117
Conversation
05804d9
to
bc87d15
Compare
...java/org/apache/maven/tools/plugin/extractor/annotations/scanner/MojoAnnotationsScanner.java
Show resolved
Hide resolved
931f8e6
to
4a5998a
Compare
maven-plugin-tools-generators/src/main/resources/help-class-source.vm
Outdated
Show resolved
Hide resolved
939348f
to
07a5f84
Compare
@kwin @slawekjaranowski I've rebased, cleaned up and added an IT. The base maven version has been reverted to 3.2.5 so that the plugin remains fully compatible with 3.x. |
mavenComponents.put( "org.apache.maven.api.Session", "${session}" ); | ||
mavenComponents.put( "org.apache.maven.api.Project", "${project}" ); | ||
mavenComponents.put( "org.apache.maven.api.MojoExecution", "${mojoExecution}" ); | ||
// TODO: apiv4: add PluginDescriptor to the api ? | ||
//mavenComponents.put( "org.apache.maven.api.descriptor.PluginDescriptor", "${plugin}" ); | ||
mavenComponents.put( "org.apache.maven.api.settings.Settings", "${settings}" ); |
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'm not sure about it ...
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.
Yeah, I was wondering about that as well. When I added the junit test, I copy/pasted an existing one and made sure it was working correcectly.
However, this is tied to maven itself and the way those parameters/components are injected.
From an API pov, using @Parameter( property = "${session}" ) Session session
is not really intuitive, whereas @Component Session session
looks simplier.
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 I remember @Component Session session
is translated to @Parameter( property = "${session}" )
- to check if still needed
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.
Yes, and the map is here to do that. So if I remove the population of the mavenComponents
with objects from the v4 api, this won't work anymore. The IT actually tests that.
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.
Also, I don't think the use of @Parameter
or @Component
should be dictated by the implementation. For example, the maven session is available as both a parameter injected by the plugin manager and a sisu bean inside the @SessionScope
. Also @Component
relates to the sisu components, but this does not have to be made explicit.
I would personally favor the @Component
approach for everything that does not come from the configuration.
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.
Me too.
@slawekjaranowski are you ok with the current PR ? |
one for build log ...
|
Trying:
|
|
hangs forever, stack:
|
Do we need the plugin to actually run ? |
I've removed the warning. |
This looks like a bug in https://github.com/apache/maven/blob/master/maven-core/src/main/java/org/apache/maven/internal/impl/PropertiesAsMap.java I've raised https://issues.apache.org/jira/browse/MNG-7597 with maven#872. |
Yes - iterator next method always return the same element 😄 |
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 plugin under test is only used for generating descriptor - it is ok for me.
JIRA issue: https://issues.apache.org/jira/browse/MPLUGIN-441
This PR includes the following:
The plugin still supports maven 3 plugins so is compatible with all the existing plugins.
The new support is provided by the annotation scanner which now supports the new package
org.apache.maven.api.plugin
in addition to the old one. The main difference is that if the new package is detected, a flag will be set on the mojo descriptor so that maven can know that the mojo is a v4 mojo and behave accordingly.