在Maven中,如何基于特定配置文件运行插件 [英] In Maven, how to run a plugin based on a specific profile
问题描述
我有一个包含3个模块的Maven项目.这些由父级pom.xml
I have a Maven project that has 3 modules. These are built by the parent pom.xml
我现在有一个要求,我需要根据所选的配置文件从子模块的pom.xml
文件之一中运行一个插件.
I now have a requirement that I need to run one plugin from inside one of the sub modules' pom.xml
files based on the profile selected.
如何指定仅在构建中使用特定配置文件时才运行此插件?
How can I specify that this plugin should only run when a certain profile is used in build?
推荐答案
Please read the documentation on build profiles here: http://maven.apache.org/guides/introduction/introduction-to-profiles.html
基本上,您需要在子模块的POM中定义一个配置文件,并将该插件包含在配置文件的plugin
部分中.使用插件的execution
标签,您可以定义插件应在哪个版本 phase 中运行.
You basically need to define a profile in your sub-module's POM and include that plugin in the profile's plugin
section. Using the plugin's execution
tag, you can define which build phase the plugin should run in.
请参见此处的示例:使用Maven配置文件控制构建执行
这篇关于在Maven中,如何基于特定配置文件运行插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!