azouiten-murex opened a new issue, #13985:
URL: https://github.com/apache/maven/issues/13985

   ### Affected version
   
   3.9.12
   
   ### Bug description
   
   ### Summary
   
   `Dependency.getLocation("version")` returns `null` for a dependency whose 
version comes from an imported BOM, when a build extension 
(`<extensions>true</extensions>`) used by the project imports the same BOM.
   
   The extension's POMs are read without location tracking. Maven caches the 
imported BOM's `dependencyManagement` once per build, so if the extension loads 
the BOM first, the project model reuses the untracked copy and gets no 
`InputLocation`.
   
   Whether location data is present depends on which side loads the BOM first. 
In my case, building from the aggregator root works, building from a 
sub-aggregator fails.
   
   ### Environment
   
   - Maven 3.9.12
   - Java 21
   - Windows 11
   
   ### Project layout
   
   ```
   root/                          (aggregator; its parent chain imports 
org.springframework:spring-framework-bom)
   ├── pom.xml
   ├── module-a/                  (sub-aggregator, parent = root)
   │   ├── pom.xml                declares build extension 
com.example:module-b:SNAPSHOT (<extensions>true</extensions>)
   │   └── core/
   │       └── pom.xml            declares org.springframework:spring-tx with 
NO <version> (managed by the BOM)
   └── module-b/                  (the build extension; its parent chain 
imports the same spring-framework-bom)
       └── pom.xml
   ```
   
   ### Steps to reproduce
   
   1. From `root/`: `mvn custom-plugin:check`
      → passes; `getLocation("version")` for `spring-tx` in `core` is set and 
points to the BOM.
   2. From `root/module-a/`: `mvn custom-plugin:check`
      → fails; `getLocation("version")` for `spring-tx` in `core` is `null`.
   
   The plugin does roughly this:
   
   ```java
   for (Dependency d : project.getOriginalModel().getDependencies()) {
       InputLocation loc = d.getLocation("version");
       loc.getSource(); // NPE in the failing case
   }
   ```
   
   ### Failure
   
   ```
   java.lang.NullPointerException: Cannot invoke 
"org.apache.maven.model.InputLocation.getSource()"
   because the return value of 
"org.apache.maven.model.Dependency.getLocation(Object)" is null
   ```


-- 
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