Skip to content

Maven 4: Consumer POM builder fails on profile-activated properties in dependency coordinates #13004

Closed

Description

@gnodet

Problem

When a project uses OS-activated profiles to set properties that are referenced in dependency <artifactId> fields, the Maven 4 consumer POM builder fails with a coordinate validation error:

ModelBuilderException: 1 problem was for org.apache.hop:hop-ui:jar:2.20.0-SNAPSHOT
    - [ERROR] 'dependencies.dependency.artifactId' for groupId='org.eclipse.platform',
      artifactId='${swt.artifactId}', type='jar' with value '${swt.artifactId}'
      does not match a valid coordinate id pattern. @ line 64, column 13

The project builds successfully up to and including compilation of the affected module — the error occurs when ReactorReaderSpy triggers installIntoProjectLocalRepository, which calls ConsumerPomArtifactTransformer.transform() to build the consumer POM.

Root Cause

In DefaultModelBuilder, isBuildRequestWithActivation() explicitly returns false for BUILD_CONSUMER:

boolean isBuildRequestWithActivation() {
    return request.getRequestType() != ModelBuilderRequest.RequestType.BUILD_CONSUMER;
}

This causes getActiveProfiles() to return an empty list for consumer POM builds, so OS-activated profiles are never applied. The DefaultConsumerPomBuilder.buildModel() compensates by passing active profile properties as user properties (line 364-367), but this only feeds interpolation — it doesn't merge the profile's dependencies or dependency management sections into the model. The coordinate validator then sees the raw ${swt.artifactId} and rejects it.

Reproducer

Apache Hop (apache/hop) — root POM uses OS-activated profiles:

<profile>
    <id>swt-unix</id>
    <activation>
        <os><name>Linux</name><family>unix</family></os>
    </activation>
    <properties>
        <swt.artifactId>org.eclipse.swt.gtk.linux.x86_64</swt.artifactId>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.eclipse.platform</groupId>
                <artifactId>${swt.artifactId}</artifactId>
                ...

The hop-ui submodule then uses this property in a dependency:

<dependency>
    <groupId>org.eclipse.platform</groupId>
    <artifactId>${swt.artifactId}</artifactId>
    <version>${org.eclipse.platform.version}</version>
</dependency>

Steps:

  1. Clone apache/hop
  2. Run mvnup apply then mvn clean package -DskipTests with Maven 4.0.0-rc-5+ and JDK 21
  3. hop-ui compiles successfully but fails during installIntoProjectLocalRepository

Expected Behavior

The consumer POM builder should resolve profile-activated properties before coordinate validation. The project builds correctly with Maven 3.

Possible Fixes

  1. Re-activate deterministic profiles (OS, JDK) in the BUILD_CONSUMER model builder path
  2. Skip coordinate validation on values that are ${...} patterns (they'll be interpolated by consumers)
  3. Ensure user properties are properly interpolated in all fields (not just versions) before validation

Related

Context

Data from maven4-testing run testing maven-4.0.x against Apache projects.

Activity

  1. added this to the 4.0.0-rc-7 milestone on Sep 1, 2026
  2. added theissue type on Sep 1, 2026
  3. added 4 commits that reference this issue on Sep 1, 2026
  4. added
    bug
    on Sep 2, 2026
  5. self-assigned this
    on Sep 2, 2026
  6. modified the milestones: 4.0.0-rc-7, 4.1.0 on Sep 2, 2026
  7. added a commit that references this issue on Sep 2, 2026
    d96bf89
  8. added a commit that references this issue on Sep 2, 2026
    a930702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugmvn4

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions