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

匿名 (未验证) 提交于 2019-12-03 02:50:02

问题:

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?

回答1:

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

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

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

http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-pom.html



回答2:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!