There is a way to execute just a Maven subproject?

116 Views Asked by At

I am wondering if there is a way to run a Maven subproject alone. I mean, in several code samples you can find a group of maven projects with a common parent. There is a way to replace parent in order to be able to run just a subproject. Lets suppose this repository https://github.com/in28minutes/spring-boot-examples There is way to run just spring-boot-tutorial-soap-web-services/ project? Thanks in advance.

1

There are 1 best solutions below

0
Ahmet M On

maven projects are identified by pom.xml and you can run any maven project individually. (Any maven goal).

  1. cd into_a_maven_project(identified by pom.xml).
  2. mvn install(this will run install phase for the project).

There are several relationships among maven projects.

  1. Parent-child
  2. Submodule
  3. Dependency

Parent-child: This relationship is used in defining a pom. For instance, When a set of pom shares a lot, you can define a parent pom(parent maven project) and reference from the child project. (reference is done from child to parent)

When you run child project, the parent project is used only to inherit the pom(copy the content of parent pom). Child pom overrides the configuration in parent pom.(child pom contains little because of the fact that required configurations copied from the parent pom)

Submodule: This relationship is used when it makes sense to build multiple projects together. In this case, you run build in the project referencing submodules. (This is not a parent child relationships, the pom is not inherited if the project is not also a parent). The result is that the submodule projects become part of the build. (The order of the build is determined by dependencies between them)

Dependency: This relationship is used when the code in a project depended by your project. The build order is calculated using this relationship.