Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

java - Where should be placed maven-compiler-plugin declaration: in <plugins> or <pluginManagement>?

I have a multi-module maven project, and I want to cause all my submodules to use maven-compiler-plugin specified in root pom.xml. Where I should place maven-compiler-plugin declaration (in root pom.xml): in <plugins> section or in <pluginManagement> section? Question also relates to maven-release-plugin too.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

These 2 sections (plugins and pluginManagement) have slightly different purposes.

The first one (plugins) is used to specify the build process of your project (and all of the child projects that inherit from the parent project). If you include some plugin into this section, it will be executed in each of the child projects regardless of its type.

The second one (pluginManagement) is used to specify common plugin settings for all of the projects that inherit from the parent project (for example, plugin version and configuration).

Speaking of the 2 plugins that you've mentioned. maven-compiler-plugin is a default plugin that will be executed whether you specify it or not. It makes sense to include it in pluginManagement and specify its configuration there. maven-release-plugin, however, is not bound to any lifecycle phase by default. So if you'd like it to be executed in all of your child projects, you'll have to add it to plugins section.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...