0

I've got a multiproject with several Modules (Microservice Modules), this Modules have a same codebase etc. persistence layer. Which i would like to extract in a separate Module (Shared Module).

The structure looks like:

Main Pom
  |- Microservice 1
  | |- module 1
  | |- module 2
  |- Microservice 2
  | |- module 1
  | |- module 2
  |- Microservice 3
  | |- module 1
  |- Shared Module

I know that i can add the "Shared Module" as a dependency to the "Microservice Modules", but than I can only build the hole project by building from the main pom.

But i want to build the Microservices Modules separately. Is it possible building the Shared Module before building only one Microservice Module.

Cœur
  • 32,421
  • 21
  • 173
  • 232
Grauzone
  • 175
  • 1
  • 10
  • Possible duplicate of [Maven Modules + Building a Single Specific Module](http://stackoverflow.com/questions/1114026/maven-modules-building-a-single-specific-module) – A_Di-Matteo Jan 13 '16 at 15:33
  • 1
    If you have defined the dependencies between your Microservice and the shared module correctly the shared module will be build before all other MS...which is the default behaviour of maven... – khmarbaise Jan 13 '16 at 20:06

1 Answers1

0

You should add the shared module as dependency for others modules.

Then, add a <modules> section (if not already exists) in main pom and list all modules.

Then, you can build only shared module from main pom by doing:

mvn install -pl :shared-module

Or you can build all modules by doing:

mvn install

Or you can build only module1 and theses dependencies (ie shared-module) by doing:

mvn install -pl :module1 -am

Or you can also list all projects you want to build manually:

mvn install -pl :shared-module,:module1
Prim
  • 2,760
  • 2
  • 13
  • 28