maven-dependency-plugin icon indicating copy to clipboard operation
maven-dependency-plugin copied to clipboard

[MDEP-910] No hardcoded groupId needed for automatic module/parent resolving in Maven 4

Open jira-importer opened this issue 1 year ago • 0 comments

Matthias Bünger opened MDEP-910 and commented

I was asking this on the dev-list last week, but as nobody could answer it (or at least nobody did answer) I got the feeling that this might be some unseen/unwanted implementation detail. If I'm wrong please give me a short explanation for my understanding and ofc close the issue:


I was double checking my Maven 4 examples and was wondering why automatic version resolving of module dependencies only works when the groupId is set fixed, but not working when using the project's variable.

To make my question clearer - let's assume a multi-module project with groupId "test.bukama.maven" and two modules ("ModuleA" and "ModuleB") where one has the other as a dependency (It's the same with parent versioning, not only module dependencies btw):

In Maven 3.9.x you can define a module dependencies using projects variables for "groupId" and "version", e.g.

<dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>ModuleA</artifactId>
      <version>${project.version}</version>
  </dependency>
</dependencies>

With automatic versioning in Maven 4 you can write

<dependencies>
    <dependency>
      <groupId>test.bukama.maven</groupId>
      <artifactId>ModuleA</artifactId>
  </dependency>
</dependencies>

and get rid fo the repeatabled versions. But when you use the project's variable for the groupId like in Maven 3.9.x

<dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>ModuleA</artifactId>
  </dependency>
</dependencies>

you get an error that the version definition is missing:

[ERROR] The project test.bukama.maven:ModuleB:0.0.1-SNAPSHOT (D:\Github\Maven4\Maven4\ModuleB\pom.xml) has 1 error [ERROR] 'dependencies.dependency.version' for test.bukama.maven:ModuleA:jar is missing. @ test.bukama.maven:ModuleB:[unknown-version], D:\Github\Maven4\Maven4\ModuleB\pom.xml, line 11, column 9

The "root" attribute is set to "true" in parent-pom and not set in the module-poms!

As I havn't found anything on the JIRA about this (but maybe overseen it), may I ask why you have to hardcode the groupId for automatic versioning to work? Why Maven 4 assumes the parents project version for the missing version but does not do the same for the groupId?

Thank you! Matthias

P.S. For me personal the best would be to only write the artifact of the projects own module (I think was working in alpha1-snapshot back then if I remember correctly), but getting rid of the version is most important for me :)


Affects: waiting-for-feedback

jira-importer avatar Mar 09 '24 14:03 jira-importer