versions icon indicating copy to clipboard operation
versions copied to clipboard

`display-dependency-updates` does not resolve versions specified via properties if `processDependencyManagementTransitive=false`

Open andreyakostov opened this issue 2 years ago • 2 comments

The issue can be reproduced with the following POM:

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

  <groupId>com.test</groupId>
  <artifactId>reproduce-version-via-property-issue</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <properties>
    <com.fasterxml.jackson.databind.version>2.13.2.2</com.fasterxml.jackson.databind.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${com.fasterxml.jackson.databind.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

</project>

Executing mvn org.codehaus.mojo:versions-maven-plugin:2.11.0:display-dependency-updates -DprocessDependencyManagementTransitive=true yields the following result:

[INFO] --- versions-maven-plugin:2.11.0:display-dependency-updates (default-cli) @ reproduce-version-via-property-issue ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.fasterxml.jackson.core:jackson-databind ....... 2.13.2.2 -> 2.13.3

While mvn org.codehaus.mojo:versions-maven-plugin:2.11.0:display-dependency-updates -DprocessDependencyManagementTransitive=false produces:

[INFO] --- versions-maven-plugin:2.11.0:display-dependency-updates (default-cli) @ reproduce-version-via-property-issue ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.fasterxml.jackson.core:jackson-databind ...
[INFO]                      ${com.fasterxml.jackson.databind.version} -> 2.13.3

andreyakostov avatar Jul 06 '22 10:07 andreyakostov

Can you contribute your example as an IT? That would be very helpful!

bmarwell avatar Jul 20 '22 18:07 bmarwell

I can see the same behavior using processDependencyManagementTransitive=false but in a multi module project the property is never resolved in the parent module regardless of whether there is an update or not.

With update available

[INFO] Reactor Build Order:
[INFO]
[INFO] reproduce-version-via-property-issue                               [pom]
[INFO] child                                                              [pom]
[INFO]
[INFO] -----------< com.test:reproduce-version-via-property-issue >------------
[INFO] Building reproduce-version-via-property-issue 1.11.0-SNAPSHOT      [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.11.0:display-dependency-updates (default-cli) @ reproduce-version-via-property-issue ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.fasterxml.jackson.core:jackson-databind ...
[INFO]                      ${com.fasterxml.jackson.databind.version} -> 2.13.3
[INFO]
[INFO]
[INFO] ---------------------------< com.test:child >---------------------------
[INFO] Building child 1.11.0-SNAPSHOT                                     [2/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.11.0:display-dependency-updates (default-cli) @ child ---
[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   com.fasterxml.jackson.core:jackson-databind ....... 2.13.2.2 -> 2.13.3

No update available, using 2.13.3

[INFO] Reactor Build Order:
[INFO]
[INFO] reproduce-version-via-property-issue                               [pom]
[INFO] child                                                              [pom]
[INFO]
[INFO] -----------< com.test:reproduce-version-via-property-issue >------------
[INFO] Building reproduce-version-via-property-issue 1.11.0-SNAPSHOT      [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.11.0:display-dependency-updates (default-cli) @ reproduce-version-via-property-issue ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.fasterxml.jackson.core:jackson-databind ...
[INFO]                      ${com.fasterxml.jackson.databind.version} -> 2.13.3
[INFO]
[INFO]
[INFO] ---------------------------< com.test:child >---------------------------
[INFO] Building child 1.11.0-SNAPSHOT                                     [2/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.11.0:display-dependency-updates (default-cli) @ child ---
[INFO] No dependencies in Dependencies have newer versions.

parent pom

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

  <groupId>com.test</groupId>
  <artifactId>reproduce-version-via-property-issue</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <properties>
    <com.fasterxml.jackson.databind.version>2.13.2.2</com.fasterxml.jackson.databind.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${com.fasterxml.jackson.databind.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <modules>
    <module>child</module>
  </modules>

</project>

child pom

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

  <parent>
    <groupId>com.test</groupId>
    <artifactId>reproduce-version-via-property-issue</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>
  <artifactId>child</artifactId>
  <packaging>pom</packaging>

  <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
  </dependencies>

</project>

merikan avatar Jul 28 '22 14:07 merikan

The same for me with the goal "versions:dependency-updates-report". As soon as I set processDependencyManagementTransitive=false the HTML report contains only placeholders in the "current version" column when the version is defined in a pom property.

TorstenKruse avatar Oct 26 '22 07:10 TorstenKruse

Ah yes, project.getOriginalModel() (which is what is used processDependencyManagementTransitive=false) if is not interpolated. Hence, property values are not resolved.

jarmoniuk avatar Oct 26 '22 18:10 jarmoniuk