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

   ### Affected version
   
   4.0.0-rc-7 (also 4.0.0-rc-6 and current master 4.1.0-SNAPSHOT)
   
   ### Bug description
   
   A project's parent is a SNAPSHOT that is only available from a repository 
declared in a profile of the root POM. The profile is activated on the command 
line (`-P` or a property). Maven 3.9.x / 3.10.0 resolves the parent from that 
repository. Maven 4 ignores the profile repository and queries only `central`, 
so the build fails.
   
   The problem only shows up when the reactor contains modules. Building the 
root POM alone (`-N`) works with Maven 4 too.
   
   Found while building `apache/maven-parent` with parent 
`org.apache:apache:41-SNAPSHOT` and `-Puse-apache-snapshots` in 
`.mvn/maven.config`.
   
   #### Reproducer
   
   `pom.xml`:
   ```xml
   <project xmlns="http://maven.apache.org/POM/4.0.0";>
     <modelVersion>4.0.0</modelVersion>
     <parent>
       <groupId>org.apache</groupId>
       <artifactId>apache</artifactId>
       <version>41-SNAPSHOT</version>
       <relativePath />
     </parent>
     <groupId>org.example</groupId>
     <artifactId>root</artifactId>
     <version>1.0-SNAPSHOT</version>
     <packaging>pom</packaging>
     <modules>
       <module>child</module>
     </modules>
     <profiles>
       <profile>
         <id>use-apache-snapshots</id>
         <repositories>
           <repository>
             <id>apache.snapshots</id>
             <url>https://repository.apache.org/snapshots</url>
             <releases><enabled>false</enabled></releases>
           </repository>
         </repositories>
       </profile>
     </profiles>
   </project>
   ```
   
   `child/pom.xml`:
   ```xml
   <project xmlns="http://maven.apache.org/POM/4.0.0";>
     <modelVersion>4.0.0</modelVersion>
     <parent>
       <groupId>org.example</groupId>
       <artifactId>root</artifactId>
       <version>1.0-SNAPSHOT</version>
     </parent>
     <artifactId>child</artifactId>
     <packaging>pom</packaging>
   </project>
   ```
   
   Run with an empty local repository:
   ```
   mvn -Dmaven.repo.local=/tmp/empty-repo -Puse-apache-snapshots validate
   ```
   
   #### Expected
   
   `BUILD SUCCESS`: `org.apache:apache:pom:41-SNAPSHOT` is resolved from 
`apache.snapshots`, as in Maven 3.9.16 and 3.10.0.
   
   #### Actual (4.0.0-rc-7)
   
   ```
   [ERROR]   The project org.example:root:1.0-SNAPSHOT (.../pom.xml) has 2 
errors
   [ERROR]     Non-resolvable parent POM: The following artifacts could not be 
resolved: org.apache:apache:pom:41-SNAPSHOT (absent): Could not find artifact 
org.apache:apache:pom:41-SNAPSHOT (remote repositories: central 
(https://repo.maven.apache.org/maven2, default, releases)) and parent could not 
be found in reactor @ line 4, column 3: One or more requests failed
   ```
   
   Only `central` is listed among the remote repositories. `apache.snapshots` 
from the active profile is missing.
   
   #### Observations
   
   | Maven version | Result |
   |---|---|
   | 3.9.16 | OK |
   | 3.10.0 | OK |
   | 4.0.0-rc-6 | FAIL |
   | 4.0.0-rc-7 | FAIL |
   | 4.1.0-SNAPSHOT (master) | FAIL |
   | 4.0.0-rc-7 with `-N` | OK |
   
   - Same result whether the profile is activated by `-P` (also via 
`.mvn/maven.config`) or by property activation (`-Dapache.snapshots`).
   - The number of errors grows with the number of modules (18 in 
`apache/maven-parent`), and all of them are reported against the root project. 
So the root POM seems to be re-read as a parent for each module, without the 
active profile's repositories.
   
   #### Environment
   
   - Java 26.0.2 (Temurin), macOS
   


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