You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2022/01/17 13:03:00 UTC

[jira] [Commented] (MNG-7392) External test dependency's transitive internal dependency not regarded for build ordering

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

Michael Osipov commented on MNG-7392:
-------------------------------------

You should turn that into a sample.

> External test dependency's transitive internal dependency not regarded for build ordering
> -----------------------------------------------------------------------------------------
>
>                 Key: MNG-7392
>                 URL: https://issues.apache.org/jira/browse/MNG-7392
>             Project: Maven
>          Issue Type: Bug
>            Reporter: Peter Palaga
>            Priority: Major
>
> Not 100% sure this is a bug. In any case, it is an interesting corner case and I feel a need to write it down somewhere. 
> Lets have a source tree like the following
> {code}
> org.foo:parent
> |- org.foo:a
> `- org.foo:b
> {code}
> Where "a before b" is the order of the {{<modules>}} in {{org.foo:parent}}
> Further, {{org.foo:a}} depends on {{org.bar:external}} in scope test. Note that {{org.bar:external}} is external, i.e. not a part of the current tree/reactor.
> And finally, {{org.bar:external}} depends on {{org.foo:b}}.
> I'd naively expect maven to be able to figure out that {{org.foo:b}} needs to get built before {{org.foo:a}}, because otherwise {{org.foo:a}} cannot be built due to a missing transitive dependency {{org.foo:b}}.
> But in reality, Maven is not able to do that. It orders {{org.foo:a}} before {{org.foo:b}} in the reactor and the build fails.
> Reordering the {{<module>}} elements in {{org.foo:parent}} is a workaround for stock Maven, but apparently it does not work for mvnd which still attempts to build {{org.foo:a}} and {{org.foo:b}} in parallel. A workaround valid for both mvn and mnvd is to add the following "virtual" dependency to {{org.foo:a}}:
> {code:xml}
> <dependency>
>     <groupId>org.foo</groupId>
>     <artifactId>b</artifactId>
>     <version>${project.version}</version>
>     <type>pom</type>
>     <scope>test</scope>
>     <exclusions>
>         <exclusion>
>             <groupId>*</groupId>
>             <artifactId>*</artifactId>
>         </exclusion>
>     </exclusions>
> </dependency>
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)