Skip to content

Cross-project ${revision} pollution (Maven CI-Friendly Versions) #1984

Open
@stechio

Description

@stechio
Component Version
m2e 2.8.0.20250224
Eclipse IDE 4.35.0.20250306

I'm struggling with an issue already reported years ago (Bug 564796 - Revision of parent POM leaks into project).

CURRENT FAULTY BEHAVIOR

When some projects leveraging the Maven CI-Friendly Versions feature share parent POMs within the same workspace, the ${revision} placeholders of the parent POM are replaced by the revision of the dependent POM instead of being flattened to its own revision.

Let's say the workspace contains two projects:

  • parent-project, whose POM declares:

    <groupId>X</groupId>
    <artifactId>parent-project</artifactId>
    <version>${revision}</version>
    <packaging>pom</packaging>
    
    <properties>
      <revision>1.0-SNAPSHOT</revision>
    </properties>
    
    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>X</groupId>
          <artifactId>parent-project-mod1</artifactId>
          <version>${revision}</version>
        </dependency>
      </dependencies>
    </dependencyManagement>
  • dependent-project (depending on parent-project), whose POM declares:

    <parent>
      <groupId>X</groupId>
      <artifactId>parent-project</artifactId>
      <version>1.0-SNAPSHOT</version>
    </parent>
    
    <artifactId>dependent-project</artifactId>
    <version>${revision}</version>
    
    <properties>
      <revision>3.5-SNAPSHOT</revision>
    </properties>
    
    <dependencies>
      <dependency>
        <groupId>X</groupId>
        <artifactId>parent-project-mod1</artifactId>
      </dependency>
    </dependencies>

The effective POM of dependent-project looks like this:

<parent>
  <groupId>X</groupId>
  <artifactId>parent-project</artifactId>
  <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>dependent-project</artifactId>
<version>3.5-SNAPSHOT</version>

<properties>
  <revision>3.5-SNAPSHOT</revision>
</properties>

<dependencies>
  <dependency>
    <groupId>X</groupId>
    <artifactId>parent-project-mod1</artifactId>
    <version>3.5-SNAPSHOT</version> <!-- WRONG! Should be 1.0-SNAPSHOT -->
  </dependency>
</dependencies>

Apparently, m2e doesn't provide a resolution boundary between projects to isolate CI-Friendly versions belonging to distinct scopes — it just brings all the POM hierarchy together, then resolves ALL the placeholders without caring of their scope.

EXPECTED BEHAVIOR

m2e should flatten the ${revision} placeholders in parent POM (just like the resolveCiFriendliesOnly flattenMode of org.codehaus.mojo:flatten-maven-plugin) before linking the dependent POM hierarchy.

For the purpose, IMO, inside m2e the dependent POM should not link directly the parent POM; instead, it should link the flattened parent POM (re-generated and cached anytime the parent POM is changed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions