Skip to content

Maven 4 loads modules in project, even if they are not included into root pom #11114

@zulkar

Description

@zulkar

Affected version

maven4-rc4

Bug description

  1. Consider next project structure: parent and child

pom.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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>org.example</groupId>
   <artifactId>maven4-test-with-profiles</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <profiles>
       <profile>
           <id>one</id>
           <modules>
               <module>m1</module>
           </modules>
       </profile>
   </profiles>

</project>
  1. Subproject is also pretty simple
    m1/pom.xml:
<parent>
       <groupId>org.example</groupId>
       <artifactId>maven4-test-with-profiles</artifactId>
       <version>1.0-SNAPSHOT</version>
   </parent>
   <artifactId>m1</artifactId>
  1. I use maven4-rc4

  2. When I compile the project using ‘mvn compile` I got only maven4-test-with-profiles in reactor. When I run 'mvn -P one compile’ I got two modules in reactor - maven4-test-with-profiles and m1. Everything is ok.

  3. Now, lets change model (with schemas) to 4.1.0

  4. Regardless of profile flags, m1 is always included into reactor. Even if you run 'mvn -P!one compile’ reactor will contain m1. That means, that you cannot build the project, if m1 contains code/tests which by some reasons are not valid without the profile.

Is it expected behaviour? Documentation says https://maven.apache.org/whatsnewinmaven4.html - However, Maven does not build subprojects unless they are linked from the root POM file.
So, there’s nothing changed in maven4.

We can change modules tag to subprojects, it does not affect the behaviour.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions