You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Martin Kanters (Jira)" <ji...@apache.org> on 2021/11/05 15:56:00 UTC

[jira] [Commented] (MNG-7310) Maven loads extension from another submodule

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

Martin Kanters commented on MNG-7310:
-------------------------------------

I've been debugging it for a while, but I still have no clue.

I verified that the [lifecyclesMap|https://github.com/apache/maven/blob/c3962c1a6c0b40abbfb12740253437f6431b234b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java#L54] does change during the Maven build. The spring-cloud-contact-maven-plugin's lifecycle gets added to the DI container, never removed (in both Maven 4 and 3.8.3).
The point is that in Maven 4 the lifecycle is added earlier in the Maven build, than in Maven 3.8.3.
In Maven 4 it's added before the [model validation|https://github.com/apache/maven/blob/f582ce88fc5f6db10f631959bab5acfbe1f58bb5/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java#L414] happens (this is where it breaks). From DefaultMaven's entrypoint, this is [buildGraph( session );|https://github.com/apache/maven/blob/965aaa53da5c2d814e94a41d37142d0d6830375d/maven-core/src/main/java/org/apache/maven/DefaultMaven.java#L253]

In Maven 3.8.3 the extension's lifecycle is added later, during the DefaultMaven's [lifecycleStarter.execute( session );|https://github.com/apache/maven/blob/965aaa53da5c2d814e94a41d37142d0d6830375d/maven-core/src/main/java/org/apache/maven/DefaultMaven.java#L337]

I don't know Plexus DI and Guice DI well enough to figure out what could be the problem.

> Maven loads extension from another submodule
> --------------------------------------------
>
>                 Key: MNG-7310
>                 URL: https://issues.apache.org/jira/browse/MNG-7310
>             Project: Maven
>          Issue Type: Bug
>    Affects Versions: 4.0.0-alpha-1
>            Reporter: Martin Kanters
>            Priority: Major
>         Attachments: demo-plugins.zip
>
>
> With the latest Maven master, I'm not able to build a certain multi module project.
> It fails with the following error:
> C:\work\apache\demo>mvn validate
>  [INFO] Scanning for projects...
>  ...
>  [ERROR] The build could not read 1 project -> [Help 1]
>  [ERROR]
>  [ERROR] The project com.example:demo2:0.0.1-SNAPSHOT (C:\work\apache\demo\demo2\pom.xml) has 1 error
>  [ERROR] 'build.plugins.plugin.version' for org.springframework.cloud:spring-cloud-contract-maven-plugin must be a valid version but is '${project.version}'. @ org.apache.maven:maven-core:4.0.0-alpha-1-SNAPSHOT:default-lifecycle-bindings
> The project looks as follows:
> parent
>  – demo (module containing plugin "spring-cloud-contract-maven-plugin")
>  – demo2 (module)
> "demo2" has no dependency on "demo" and the parent of "demo2" is "parent"..
>  Somehow, the plugin from "demo" leaks into "demo2", which I've verified is the case during a debug session.
> I'm still unsure of a couple of things:
>  - Does it only happen with the "spring-cloud-contract-maven-plugin" plugin?
>  - Where does ${project.version} come from? (I've not defined it)
> I've done a bisect and tracked it down to the following commit:
>  [[MNG-5577] Convert maven-core to JSR 330|https://github.com/apache/maven/commit/9567da2bc889a94f5c3b692b4afb310ddbacd6e5]
> Subject project is attached. Reproduce with the current master of Maven: mvn validate.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)