Jithin Pavithran
Jithin Pavithran

Reputation: 1351

Can a module have the same artifactID as parent ? | Maven

I have a maven project of following structure:

parent (artifactID: ABC)
 |
 |---- module 1 (artifactID: ***)
 |---- module 2 (artifactID: XYZ)

Can module 1 have artifactID: ABC?

My parent module is only meant to package the modules together. It doesn't have any source code of its own.

Does Maven take into account the hierarchy of modules to distinguish two modules? If not why?
It shouldn't be difficult to distinguish two guys with the same name but in different places.

Upvotes: 0

Views: 998

Answers (2)

SilverNak
SilverNak

Reputation: 3381

When the groupId is identical, the artifactId must be different.

As the maven docs state, the groupId has to be universally unique and the artifactId must be unique within the groupId.

groupId

A universally unique identifier for a project. It is normal to use a fully-qualified package name to distinguish it from other projects with a similar name

artifactId

The identifier for this artifact that is unique within the group given by the group ID.

Upvotes: 4

Rich Duncan
Rich Duncan

Reputation: 1923

Sure - if the groupId is different :)

If the GAV is the same, then the artifact is the same and therefore your parent and artifact would be overwriting each other if you deploy them to say Artifactory or Nexus

Upvotes: 2

Related Questions