Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 203
LuckyLuke Avatar asked Feb 02 '23 08:02

LuckyLuke


1 Answers

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).

like image 72
Dev Avatar answered Feb 12 '23 09:02

Dev