user2248702
user2248702

Reputation: 3008

Multi-module project structure Maven

I have a project that contains 2 applications and a core which will be contained in both which handles things like database access. I have a separate module for each application but I's not sure if I should use another module for the core or put it in the parent module.

Project+-+-+src                            
         |                                 
         +-+App1                           
         |                                 
         +-+App2                           

or using a seperate module:

Project+-+-+Core                           
         |                                 
         +-+App1                           
         |                                 
         +-+App2 

Upvotes: 0

Views: 47

Answers (1)

M A
M A

Reputation: 72884

Create Core as a separate module and have App1 and App2 depend on it. You can manage the dependency in the parent POM:

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

Dependency tree:

Project+-+-+-+Core                           
         |                                 
         +-+-+App1   
         | |
         | +-+-+Core                        
         |                                 
         +-+-+App2
           |
           +-+-+Core 

See this link from the Maven project page for dependency management.

Upvotes: 1

Related Questions