user8093442
user8093442

Reputation:

Maven repo module and parent at the same level

I have created a simple maven project with a parent pom and a module pom. When i execute a mvn clean install i notice that the parent and the module are in the same level.

Structure of the project in the local repo:

-parent folder
-module folder

While I expected something like that:

-parent folder
   +—-module folder

Is this normal ?

What happened if two modules have the same name in this case ?

Upvotes: 0

Views: 155

Answers (1)

SilverNak
SilverNak

Reputation: 3381

Assuming you are talking about the local repo usually located at ~/.m2/repository, yes, that is normal. You have to distinguish between the folder layout within the repository and the folder layout for your development.

As mentioned in this question, the artifacts are always in a folder structure according to their coordinates (groupId, artifactId and version).

groupIdSplitAtDots/artifactId/version

Whether some artifacts are modules of another is completely irrelevant for the directory-layout of the local repository.

If you have e.g. the artifacts com.organisation.topic:artifact-parent:1.2, com.organisation.topic:artifact-module1:1.2 and com.organisation.topic:artifact-module2:1.2, the folder structure will be:

com
|-- organisation
    |-- topic
        |-- artifact-parent
            |-- 1.2
        |-- artifact-module1
            |-- 1.2
        |-- artifact-module2
            |-- 1.2

Note, that for development it is usually a good idea to have the parent module in a parent folder, resulting in a layout like this:

artifact-parent
|-- artifact-module1
|-- artifact-module2

As per your second question, identical module names (artifactIds) are not allowed. Regarding the artifactId the docs state:

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

Upvotes: 2

Related Questions