在Maven中,如何基于特定配置文件运行插件 [英] In Maven, how to run a plugin based on a specific profile

查看:206
本文介绍了在Maven中,如何基于特定配置文件运行插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆