0

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 ?

  • Can you explain more detail what your problem is? Can you format the post better ...otherwise it's hard to read... – khmarbaise Jul 21 '18 at 17:27
  • I added more details, i would like to know if its normal that parent folder and module folder in my local repo are on the same level. I expected to have module folder in the parent folder –  Jul 21 '18 at 17:38

1 Answers1

2

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.

SilverNak
  • 3,283
  • 4
  • 28
  • 44
  • Ok so its normal to have parent and module in the same level in my repo but imagine the case i have two modules with the same how its manages in my repo ? –  Jul 21 '18 at 18:18
  • @mrt66 Sorry, I overread your second question. I updated my answer accordingly – SilverNak Jul 21 '18 at 18:19