enforcing maven 3 - when to use maven enforcer plugin? when to use pom prerequisites element?

后端 未结 2 972
旧巷少年郎
旧巷少年郎 2021-02-13 11:40

The two main approaches for enforcing maven 3 seem to be:

  • maven-enforcer-plugin, and
  • pom.xml element.

相关标签:
2条回答
  • 2021-02-13 12:11

    Prerequisites are deprecated, and you should use the enforcer plugin. MNG-5297 requests a documentation update to clarify this.

    The maven-enforcer-plugin FAQ explains the difference:

    Why can't I just use the prerequisites tag in the pom?

    The prerequisites tag was designed to be used by tools like plugins. It will work for regular projects, but it isn't inherited to their children. If it is set in a parent reactor, then Maven will do the check. However if one of the children are built, the check is not performed. The enforcer plugin is designed to allow centralized control over the build environment from a single "super-pom", and to allow greater flexibility in version specification by supporting ranges.

    In addition, note that prerequisites do not work with Maven 3.

    0 讨论(0)
  • 2021-02-13 12:24

    The Maven pom prerequisites approach may be more appropriate for smaller, simpler projects. This approach will be lighter weight as it will not require the maven-enforcer-plugin to be downloaded.

    The maven-enforcer-plugin approach may be more suitable if you have children projects that you wish to inherit the maven 3 requirement from the parent. pom prerequisites is not inherited by children projects.

    0 讨论(0)
提交回复
热议问题