Skip to content

Model builder tests read the repository's own reactor POMs #13448

Closed

Description

@slachiewicz

Affected version

4.0.x and master (impl/maven-impl tests)

Bug description

Model builder tests that run on an ApiRunner session build Maven's own reactor before the POM under test. A profile added to the root pom.xml of this repository can then fail tests that never reference it.

ApiRunner's session throws IllegalStateException from getRootDirectory(). DefaultModelBuilder.buildBuildPom() then falls back to RootLocator.findMandatoryRoot(top), which walks up from the test POM (for example src/test/resources/poms/factory/complex.xml) to the first .mvn directory: the root of the checkout. loadFromRoot() reads that pom.xml and every subproject, activates their profiles with the request's system properties only, and throws if any of them reports an error, before it finds that the test POM is not in that reactor.

#13442 hit this: a <jdk>[27,)</jdk> activation in the root POM failed ComplexActivationTest, because the request carries only myproperty and JdkVersionProfileActivator reports a missing java.version as an ERROR:

[ERROR] ComplexActivationTest.testAndConditionInActivation:63 » ModelBuilder 1 problem was  for test:test:pom:0.1-SNAPSHOT
    - [ERROR] Failed to determine Java version for profile jdk27-skip-spotless @ line 998, column 9

The location is in the root pom.xml, but the problem is reported against test:test. The call stacks are in #13442 (comment).

Scope

JDK activation is the trigger seen so far, but not the only one. Any ERROR problem while reading or activating any POM of this repository fails these tests. Among the activators:

  • JdkVersionProfileActivator: error when java.version is missing, which it always is in these requests.
  • PropertyProfileActivator: error for an empty property name.
  • ConditionProfileActivator: error when a condition fails to parse or evaluate.
  • FileProfileActivator: error when the file check throws.
  • OperatingSystemProfileActivator falls back to the JVM's os.* values, so an OS-activated root profile is evaluated against the host that runs the tests.

The tests also depend on the reactor's layout: a subproject that is missing or fails to parse in the checkout breaks them.

Counted on maven-4.0.x with a temporary print in loadFilePom, mvn test -pl impl/maven-impl (613 tests):

Test class Root POM loads POM loads in total
DefaultModelBuilderTest 35 1501
ComplexActivationTest 2 78
TestApiStandalone 1 38
RequestTraceTest 1 38

Each ComplexActivationTest method reads the 39 POMs of this repository to build one test POM.

Possible fixes

  • Give the test sessions a root directory (the test resources directory), so buildBuildPom() does not fall back to RootLocator.
  • Or put a .mvn marker next to the test POMs, so RootLocator stops there.

#13442 and #13439 worked around it by activating the profile through java.specification.version, which is inactive rather than an error when the property is missing.

Activity

  1. added a commit that references this issue on Oct 14, 2026
    4fa35fc
  2. added a commit that references this issue on Oct 14, 2026
    9955c0a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmvn4

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions