0

I have project which consists of two separate sub-projects and some common code, with the sub-projects needing to be built independently.

What would be the recommended Maven project structure for this scenario?

I've already tried something like this:

-project-parent
   -pom.xml
-projectA-parent
   -pom.xml
-projectA
   -pom.xml
-projectB-parent
   -pom.xml
-projectB
   -pom.xml
-common
   -pom.xml

The parents for A and B are responsible for building the modules projectA/common and projectB/common. In the project parent POM I would define some common dependencies.

Is there an alternative that does not use a parent hierarchy? Something that, e.g., uses build profiles which can be used to build either projectA or projectB with their dependencies (common)?

matthjes
  • 671
  • 7
  • 20

1 Answers1

0

Take a look at the accepted answer of Maven Modules + Building a Single Specific Module.

So you may need just one parent for all modules an then use the pl-option to select the modules for the build.

Community
  • 1
  • 1
Rob
  • 5,353
  • 33
  • 34