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

Karl Heinz Marbaise edited comment on MNG-7920 at 11/18/23 2:10 PM:
--------------------------------------------------------------------

So after diving a bit deeper into this... it looks like the resulting 
{{pom.xml}} should be made the main artifact of the {{bom}} packaged project 
because in the end it's the main artifact of the module. For example if we have 
a normal pom packaged module it works the same. The {{maven-install-plugin}} 
already WARNs exactly about that. Furthermore is my opinion that the 
{{maven-install-plugin}} should not needed to be changed because the main 
artifact is the resulting {{{}pom{}}}. 
So the core should assign the interpolated (bom) as the main artifact 
(packaging: pom) while the {{pom-build}} is already attached as classifier 
based artifacts.

I created a full reproducer to look more in detail on the problems:

Lets start with the {{bom}} packaging module which contains the following 
(original pom):
{code:xml}
  <parent>
    <groupId>maven.four.bug.7920</groupId>
    <artifactId>bom-example</artifactId>
  </parent>

  <packaging>bom</packaging>
  <artifactId>bom</artifactId>
  <name>Maven Bug :: 7920 :: BOM</name>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
      </dependency>
    </dependencies>
  </dependencyManagement>
..
{code}
So the above {{pom.xml}} is converted into {{pom}} packaging based 
{{{}pom.xml{}}}.. it looks like this:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>
  <groupId>maven.four.bug.7920</groupId>
  <artifactId>bom</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>Maven Bug :: 7920 :: BOM</name>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>5.10.1</version>
      </dependency>
....
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.24.2</version>
      </dependency>
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-guava</artifactId>
        <version>3.24.2</version>
      </dependency>
.......
    </dependencies>
  </dependencyManagement>
</project>
{code}
The list of issues I found from my point of view:
 # So the first issue I can identify is that the integrated artifacts:
{code:xml}
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
      </dependency>
{code}
do not contain a version number.

 # The second issue I can identify is that it contains all bom's resolved which 
are from the module parent (see junit-jupiter, assertj, mockito), but 
*{*}not{*}* the test scoped dependencies of the {{mod-1}} (added a dependency 
to {{junit:junit:4.13.2}} and a non test scoped dependency 
{{{}commons-collections:commons-collections:3.2.2{}}}.

>From my point of view the resulting {{pom.xml}} should look like this:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>
  <groupId>maven.four.bug.7920</groupId>
  <artifactId>bom</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>Maven Bug :: 7920 :: BOM</name>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>
{code}
It should contain things like: URL, name, organization, developers, licenses, 
issueManagement, ciManagement(no),distributionManagement(no), repositories (no)

The link to the full repoducer: 
[https://github.com/khmarbaise/maven-bugs/tree/master/MNG-7920]


was (Author: khmarbaise):
So after diving a bit deeper into this... it looks like the resulting 
{{pom.xml}} should be made the main artifact of the {{bom}} packaged project 
because in the end it's the main artifact of the module. For example if we have 
a normal pom packaged module it works the same. The {{maven-install-plugin}} 
already WARNs exactly about that. Furthermore is my opinion that the 
{{maven-install-plugin}} should not needed to be changed because the main 
artifact is the resulting {{pom}}. 
So the core should assign the interpolated (bom) as the main artifact 
(packaging: pom) while the {{pom-build}} is already attached as classifier 
based artifacts.

I created a full reproducer to look more in detail on the problems:

Lets start with the {{bom}} packaging module which contains the following 
(original pom):
{code:xml}
  <parent>
    <groupId>maven.four.bug.7920</groupId>
    <artifactId>bom-example</artifactId>
  </parent>

  <packaging>bom</packaging>
  <artifactId>bom</artifactId>
  <name>Maven Bug :: 7920 :: BOM</name>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
      </dependency>
    </dependencies>
  </dependencyManagement>
..
{code}

So the above {{pom.xml}} is converted into {{pom}} packaging based 
{{pom.xml}}.. it looks like this:

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>
  <groupId>maven.four.bug.7920</groupId>
  <artifactId>bom</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>Maven Bug :: 7920 :: BOM</name>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>5.10.1</version>
      </dependency>
....
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.24.2</version>
      </dependency>
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-guava</artifactId>
        <version>3.24.2</version>
      </dependency>
.......
    </dependencies>
  </dependencyManagement>
</project>
{code}


The list of issues I found from my point of view:

# So the first issue I can identify is that the integrated artifacts:
{code:xml}
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
      </dependency>
{code}
do not contain a version number.
# The second issue I can identify is that it contains all bom's resolved which 
are from the module parent (see junit-jupiter, assertj, mockito), but **not** 
the test scoped dependencies of the  {{mod-1}} (added a dependency to 
{{junit:junit:4.13.2}} and a non test scoped dependency 
{{commons-collections:commons-collections:3.2.2}.

>From my point of view the resulting {{pom.xml}} should look like this:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>
  <groupId>maven.four.bug.7920</groupId>
  <artifactId>bom</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>Maven Bug :: 7920 :: BOM</name>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-1</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>maven.four.bug.7920</groupId>
        <artifactId>mod-2</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>
{code}
 
It should contain things like: URL, name, organization, developers, licenses, 
issueManagement, ciManagement(no),distributionManagement(no), repositories (no)

The link to the full repoducer: 
https://github.com/khmarbaise/maven-bugs/tree/master/MNG-7920


> Usage of packaging BOM fails in maven-install-plugin
> ----------------------------------------------------
>
>                 Key: MNG-7920
>                 URL: https://issues.apache.org/jira/browse/MNG-7920
>             Project: Maven
>          Issue Type: Bug
>          Components: Deployment
>    Affects Versions: 4.0.0-alpha-8
>            Reporter: Karl Heinz Marbaise
>            Priority: Critical
>             Fix For: 4.0.0, 4.0.0-alpha-9
>
>
> Using to use the {{bom}} packaging in a module it will fail with:
> {code}
> [INFO] 
> --------------------------------------------------------------------------------------------------------------------------
> [ERROR] Failed to execute goal 
> org.apache.maven.plugins:maven-install-plugin:3.1.1:install (default-install) 
> on project bom: The packaging plugin for this project did not assign a main 
> file to the project but it has attachments. Change packaging to 'pom'. -> 
> [Help 1]
> {code}
> The bom module looks like this:
> {code:xml}
> <project
>   xmlns="http://maven.apache.org/POM/4.1.0";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 
> http://maven.apache.org/maven-v4_1_0.xsd";>
>   <modelVersion>4.1.0</modelVersion>
>   <parent>
>     <groupId>....maven4</groupId>
>     <artifactId>bom-example</artifactId>
>   </parent>
>   <packaging>bom</packaging>
>   <artifactId>bom</artifactId>
>   <dependencyManagement>
>     <dependencies>
>       <dependency>
>           <groupId>...maven4</groupId>
>           <artifactId>mod-1</artifactId>
>       </dependency>
>       <dependency>
>           <groupId>....maven4</groupId>
>           <artifactId>mod-2</artifactId>
>       </dependency>
>     </dependencies>
>   </dependencyManagement>
> </project>
> {code}
> I would assume that I need to upgrade the maven-install-plugin which is 
> capable of handling that...but I assumed that this conversion is done by core?



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

Reply via email to