LuckyLuke LuckyLuke - 18 days ago 4
Java Question

What is inherited in Maven projects

When making a parent Maven project, what does the child projects inherit?

After what I understand groupId is inherited by the parent project too, but where can I actually see that in documentation?

This is all thats listed (after what I found).

dependencies
developers and contributors
plugin lists
reports lists
plugin executions with matching ids
plugin configuration


http://maven.apache.org/pom.html

Dev Dev
Answer

Almost anything that has been specified in a parent is inherited by the child. It's actually better to ask "What is not inherited by a child project in Maven?" as that would probably be a shorter list.

Examples of things not included in the list at maven inheritance docs (which you listed in your question) that are also inherited would be scm tag, distributionManagement tag, and any declared properties (I use this quite a bit for setting default character encoding).

The certain way to find out if a child project has inherited something from a parent is to run the help:effective-pom mojo on the child project. This will show you the complete effective pom at build time for that project which will have inherited elements included. Example invocation below.

mvn help:effective-pom

Some IDEs also have tools for viewing the 'effective pom' of a project (i.e. M2E eclipse plugin).

Comments