stevenschlansker opened a new issue, #11397:
URL: https://github.com/apache/maven/issues/11397

   ### Affected version
   
   3.9.11
   
   ### Bug description
   
   I build a multi-module project that includes a bom, and components that use 
that bom for convenience.
   It seems that the bom dependency of type import does not count as a 
dependency as far as the `-am` option is concerned, and it gets skipped if used.
   
   Example project:
   
   `pom.xml`
   
   ```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>org.jdbi.internal</groupId>
       <artifactId>test-maven-bom-parent</artifactId>
       <version>1-SNAPSHOT</version>
       <packaging>pom</packaging>
   
       <modules>
           <module>test-bom</module>
           <module>test-consumer</module>
       </modules>
   </project>
   ```
   
   `test-bom/pom.xml`
   
   ```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>
   
       <parent>
           <groupId>org.jdbi.internal</groupId>
           <artifactId>test-maven-bom-parent</artifactId>
           <version>1-SNAPSHOT</version>
           <relativePath>..</relativePath>
       </parent>
   
       <artifactId>test-bom</artifactId>
       <packaging>pom</packaging>
   
       <dependencyManagement>
           <dependencies>
               <dependency>
                   <groupId>org.jdbi</groupId>
                   <artifactId>jdbi3-core</artifactId>
                   <version>3.50.0</version>
               </dependency>
           </dependencies>
       </dependencyManagement>
   </project>
   ```
   
   `test-consumer/pom.xml`
   
   ```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>
   
       <parent>
           <groupId>org.jdbi.internal</groupId>
           <artifactId>test-maven-bom-parent</artifactId>
           <version>1-SNAPSHOT</version>
           <relativePath>..</relativePath>
       </parent>
   
       <artifactId>test-consumer</artifactId>
   
       <dependencyManagement>
           <dependencies>
               <dependency>
                   <groupId>org.jdbi.internal</groupId>
                   <artifactId>test-bom</artifactId>
                   <version>${project.version}</version>
                   <type>pom</type>
                   <scope>import</scope>
               </dependency>
           </dependencies>
       </dependencyManagement>
   
       <dependencies>
           <dependency>
               <groupId>org.jdbi</groupId>
               <artifactId>jdbi3-core</artifactId>
           </dependency>
       </dependencies>
   </project>
   ```
   
   As a developer trying to avoid building unnecessary modules, I run:
   
   ```
   % mvn -B -o clean install -am -pl test-consumer
   [INFO] 
------------------------------------------------------------------------
   [INFO] Reactor Summary for test-maven-bom-parent 1-SNAPSHOT:
   [INFO] 
   [INFO] test-maven-bom-parent .............................. SUCCESS [  0.110 
s]
   [INFO] test-consumer ...................................... SUCCESS [  0.613 
s]
   [INFO] 
------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   ```
   
   To me this is unexpected - the `test-consumer` artifact clearly has a 
SNAPSHOT dependency on `test-bom` in the current reactor, and by skipping it, 
the local repository unexpectedly does not contain current development changes 
to the `test-bom` artifact. This results either in errors (can't determine 
`jdbi3-core` version since the `test-bom` can't be found) or subtle bugs (wrong 
version of `jdbi3-core` used)
   
   ```
   [ERROR] Failed to execute goal on project test-user: Could not collect 
dependencies for project org.jdbi.internal:test-user:jar:1-SNAPSHOT
   [ERROR] Failed to read artifact descriptor for 
org.jdbi.internal:test-consumer:jar:1-SNAPSHOT
   [ERROR]      Caused by: The following artifacts could not be resolved: 
org.jdbi.internal:test-bom:pom:1-SNAPSHOT (absent): Cannot access ... in 
offline mode and the artifact org.jdbi.internal:test-bom:pom:1-SNAPSHOT has not 
been downloaded from it before.
   ```
   
   Thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to