[ 
https://issues.apache.org/jira/browse/MPLUGIN-508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17850767#comment-17850767
 ] 

ASF GitHub Bot commented on MPLUGIN-508:
----------------------------------------

gnodet commented on code in PR #286:
URL: 
https://github.com/apache/maven-plugin-tools/pull/286#discussion_r1620871349


##########
maven-plugin-plugin/src/it/v4api/src/main/java/org/apache/maven/its/v4api/FirstMojo.java:
##########
@@ -38,15 +37,12 @@
  * Test mojo for the v4 api plugin descriptor generation.
  * This mojo is not actually runnable because:
  *  - it's using a custom lifecycle which is not defined
- *  - it has a @Component dependency on ArtifactInstaller (hint=test) which 
does not exist
+ *  - it has a @Inject dependency on ArtifactInstaller (hint=test) which does 
not exist
  *
  * @since 1.2
  */
-@Mojo(
-        name = "first",
-        requiresDependencyResolution = ResolutionScope.TEST,
-        defaultPhase = LifecyclePhase.INTEGRATION_TEST)
-@Execute(phase = LifecyclePhase.GENERATE_SOURCES, lifecycle = "cobertura")
+@Mojo(name = "first", defaultPhase = "integration-test")
+@Execute(phase = "generate-sources", lifecycle = "cobertura")
 public class FirstMojo implements org.apache.maven.api.plugin.Mojo {

Review Comment:
   Maven 4 mojos have to be thread safe, so that annotation is gone.
   
   In maven 3, the `requiresDependencyResolution` and 
`requiresDependencyCollection` are currently used to collect or resolve the 
project dependencies in a given scope.  Those artifacts are then made available 
by Maven by `MavenProject.getArtifacts()`.  This brings several problems: for a 
single project, two mojos can not be run concurrently, and as we've seen, some 
mojos even require runtime + test scope resolution, and that cannot be 
provided.   In 4.x, mojos will have to use the API to retrieve collect/resolve 
the dependencies.  Hopefully the result can be cached in the session.  So the 
latest 4.x release did remove those two bits.  However, not having this 
information sounds wrong, as this would be needed in at least two scenarii:
    * it would be nice to be able to eagerly download dependencies at the 
beginning of a given build, and we'd need to know which scopes are needed for a 
given project, this could be done by analysing the build plan
    * if we experiment a bit more with the [fully concurrent 
builder](https://github.com/apache/maven/pull/1429), we need this information 
in order to know which goals depend on which projects in the reactor, so that 
the goals can be scheduled correctly
   
   So I think we'll need to add those back somehow, but they would be 
informational.  Another possibility would be to allow injecting the 
resolution/collection result in the mojo, this may require a new specific 
annotation, but that may be the best solution.
    





> Upgrade to Maven 4.x
> --------------------
>
>                 Key: MPLUGIN-508
>                 URL: https://issues.apache.org/jira/browse/MPLUGIN-508
>             Project: Maven Plugin Tools
>          Issue Type: New Feature
>    Affects Versions: 3.12.0
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>            Priority: Major
>             Fix For: 4.0.0
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to