Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin does not evaluate GroupId / ArtifactId property variables #1001

Closed
Tholian opened this issue Sep 7, 2023 · 6 comments · Fixed by #1003
Closed

Plugin does not evaluate GroupId / ArtifactId property variables #1001

Tholian opened this issue Sep 7, 2023 · 6 comments · Fixed by #1003
Labels
Milestone

Comments

@Tholian
Copy link

Tholian commented Sep 7, 2023

If th groupId of an dependency is defined in a property and this property-variable is used in the dependency the execution of mvn versions:display-dependency-updates shows some problems.

eg. following pom.xml snippet

...
<properties>
	<archunitGroupId>com.tngtech.archunit</archunitGroupId>
	<archunit.version>1.1.0</archunit.version>
</properties>

...

<dependency>
	<groupId>${archunitGroupId}</groupId>
	<artifactId>archunit</artifactId>
	<version>${archunit.version}</version>
</dependency>

will lead to this console output:

[INFO] --- versions-maven-plugin:2.16.0:display-dependency-updates (default-cli) @ myProject---
Downloading from nexus: http://myNexusRepo/nexus/content/groups/public/$%7BarchunitGroupId%7D/archunit/maven-metadata.xml

As you can see, the GroupId was not correctly determined.

Excpected behaviour is a correct usage of variables even for groupId an artifactId.

@jarmoniuk
Copy link
Contributor

I'll look into it.

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Sep 8, 2023

Strangely enough, so far I haven't been able to reproduce the issue.

I tried this test scenario:

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

    <groupId>localhost</groupId>
    <artifactId>it-display-dependency-updates-issue-1001-groupid</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <description>groupId is expressed via a Maven property</description>

    <properties>
        <dep.groupId>localhost</dep.groupId>
        <dep.version>1.0</dep.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${dep.groupId}</groupId>
            <artifactId>dummy-api</artifactId>
            <version>${dep.version}</version>
        </dependency>
    </dependencies>
</project>
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates
invoker.mavenOpts = -Dversions.outputFile=./output.txt -DoutputEncoding=UTF-8
def output = new File(basedir, "output.txt").text
assert output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*\Q1.0\E\s+->\s+\Q3.0\E\b/

and it passes with the relevant log lines:

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   localhost:dummy-api ....................................... 1.0 -> 3.0
[INFO] 

I've also tried adding a real dependency to a real-life project (module versions-maven-plugin in the versions-maven-plugin project):

  <properties>
    <dep.groupId>com.google.guava</dep.groupId>
    <dep.version>16.0</dep.version>
  </properties>

  <dependencies>
    <!-- project dependencies -->
    <dependency>
      <groupId>${dep.groupId}</groupId>
      <artifactId>guava</artifactId>
      <version>${dep.version}</version>
    </dependency>

Using the following command:

mvn org.codehaus.mojo:versions-maven-plugin:2.16.0:display-dependency-updates -pl :versions-maven-plugin

produced the following output:

[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   com.google.guava:guava ............................ 16.0 -> 32.1.2-jre

@jarmoniuk
Copy link
Contributor

jarmoniuk commented Sep 8, 2023

It looks like this does work fine (i.e. bug can't be reproduced) with 2.16.0. Could you please isolate a test project (that is, a minimal pom.xml) which does verify the issue?

NB. The goal does not use raw POM files, it gets project information from Maven with all property variables already interpolated (resolved) by Maven.

jarmoniuk added a commit to jarmoniuk/versions-maven-plugin that referenced this issue Sep 8, 2023
@slawekjaranowski
Copy link
Member

@Tholian - can you help a reproduce issue?, as you see we can not reproduce it
Without reproduce example, I will close it.

@ajarmoniuk - we can add simple IT to confirm case

@slawekjaranowski slawekjaranowski linked a pull request Sep 10, 2023 that will close this issue
slawekjaranowski pushed a commit that referenced this issue Sep 10, 2023
@slawekjaranowski slawekjaranowski added this to the next-release milestone Sep 10, 2023
@slawekjaranowski
Copy link
Member

@Tholian we add a test to confirm that working as expected
If you have another case please let us know - how to reproduce

@Tholian
Copy link
Author

Tholian commented Sep 19, 2023

Hi, I have tried to set up a test project as an example of the behavior I have seen. But indeed this is working fine.
I don't get the real difference to my life working project where I can spot that issue.

I will try to figure out what causes this misbehavior.
Thank you so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants