user2504767
user2504767

Reputation:

What are the difference between pom.xml and effective pom in Apache Maven?

Could somebody explain to me, what are are differences between the file pom.xml and the file effective pom.xml in an apache maven project?

Upvotes: 42

Views: 37018

Answers (2)

Iker Aguayo
Iker Aguayo

Reputation: 4115

The Super POM

All Maven project POMs extend the Super POM, which defines a set of defaults shared by all projects.

The Simplest POM

All Maven POMs inherit defaults from the Super POM. If you are just writing a simple project that produces a JAR from some source in src/main/java, want to run your JUnit tests in src/test/java, and want to build a project site using mvn site, you don’t have to customize anything. All you would need, in this case, is the simplest possible POM shown in The Simplest POM. This POM defines a groupId, artifactId, and version: the three required coordinates for every project.

The Effective POM

It is the merge between The Super POM and the POM from The Simplest POM.

NOTE: This info was extracted from the following link (in the link the explanation is very complete)

Upvotes: 52

Wolfgang Fahl
Wolfgang Fahl

Reputation: 15769

You can see the difference of a pom.xml and the effective pom.xml using

mvn help:effective-pom

which is describe here.

In a multi module project you'll use a parent pom.xml for defining general settings for all modules and then in each module there will only be specific settings.

The above goal will help you analyze the resulting pom that you could of course actually use instead of the parent reference.

The whole idea is by using the generalization (super-pom) / specialization (module pom) approach there is a central place where you can specify the general configuration. This is much more efficient then having to cut&paste the general parts.

Please also note that the effective pom will add the default behavior e.g. for the jar plugin so that you can debug issues like

Maven JAR Plugin 3.0.2 Error: You have to use a classifier to attach supplemental artifacts to the project instead of replacing them

with this approach. See also Maven `help:effective-pom` only generating for a single project, not all projects

Upvotes: 3

Related Questions