Search code examples
maventycho

Build maven modules from parent without parent reference


I have set up a reactor build for several modules which works nicely. My submodules do not reference the parent pom.

As I use my submodules for several products there exist multiple parent poms, so I cannot put a parent reference to the submodules anyway.

Now I want the parent pom to be able to change some settings in the submodules. How can this be achieved without referring to a parent pom?

It would be great to have some default values defined in the submodule pom which might be overruled by the parent.


Solution

  • Unless you have a parent POM reference, you cannot inherit from the parent POM. This is by design: To ensure reproducibility, the model of the build shall be computable from the POM of a module.

    The only additional sources of configuration for a Maven build are the settings.xml and the command line. So as a workaround, you may be able to build the same sources twice with different properties set on the command line.