Skip to content

Direct dependency from BOM fetches the master version instead of the feature version #372

@Bentaii

Description

@Bentaii

If a project depends directly on another through a BOM that handles the versions, the master version of the dependency is used for compilation instead of the feature version.

Our infrastructure looks like

Backend projects <- BOM for version management <- Application

Let's say we have Dependency1 whose 1.0.0-SNAPSHOT version is defined for Application in BOM.

As such, the BOM's POM looks like:

...
    <properties>
        <dependency1.version>1.0.0-SNAPSHOT</dependency1.version>
    </properties>
...
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.example</groupId>
                <artifactId>dependency1</artifactId>
                <version>${dependency1.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
...

And the Application POM looks like

Parent POM

...
    <properties>
        <bom.version>1.0.0-SNAPSHOT</bom.version>
    </properties>
...
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.example</groupId>
                <artifactId>bom</artifactId>
                <version>${bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
...

With the Application module POM looking like

...
    <dependencies>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>dependency1</artifactId>
        </dependency>
    </dependencies>
...

I created sample projects to illustrate the issue:
Dependency
BOM
Application

In those projects, p2 compiled on a "test" branch would not be able to find p1's new method if used.

This is a simplified version of our issue, but if Dependency1 itself had dependencies on another module in the same project, the indirect dependency would be properly resolved while the direct would not. My guess for this behavior is that the root POM for the project is found with the feature version and it resolves its module version with the feature, while the direct dependency uses the version resolved during build once the BOM is analyzed.

Our only workaround is creating a feature with no changes in the BOM repository so a version is generated for the feature version, but it's useless as it only contains project versions and it's also very inconvenient for devs to remember to do it or to implement in a pipeline. Any insight or advice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions