Alexandre
Alexandre

Reputation: 5135

Eclipse and Maven: How to share code among modules?

I have 1 maven project with 3 modules:

./project ./project-node ./project-master ./project-common

The first is just to allow me to execute mvn build to build all 3 modules at once.

I want to extract all common code between -node and -master to -common.

I don't know how to do it. -common has a bunch of Interfaces that are used by both -node and -master. Do I have to add project-common as a <dependency> to both? I wanted to avoid having to install project-common to the local repository every time I made a change... Looking for something lightweight as this initial stage of development.

Thanks

Upvotes: 3

Views: 648

Answers (1)

Corubba
Corubba

Reputation: 2243

If you want to use interfaces and classes of project-common within project-node and project-master, you have to add the project-common artifact as <dependency> in the pom of the projects you want to use the code in (in this case project-node and project-master). You dont need to install dependency artifacts in your local repository if they are in your build reactor. So if you run mvn compile on project, all three artifacts are in the build reactor, so maven dont look for them in the local or remote repo. No need for installing here.

Upvotes: 1

Related Questions