Maven的:什么是pluginManagement? [英] Maven: what is pluginManagement?

查看:253
本文介绍了Maven的:什么是pluginManagement?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的POM文件的一个片段。

....
        <&插件GT;
            <&插件GT;
                <&的groupId GT; org.apache.maven.plugins< /的groupId>
                <&的artifactId GT; Maven的依赖,插件< / artifactId的>
                <&版GT; 2.4< /版本>
                <&执行GT;
                    <执行与GT;
                        <阶段>安装与LT; /阶段>
                        <目标>
                            <&目标GT;复制依赖性和LT; /目标>
                        < /目标>
                        <结构>
                            ......
                        < /结构>
                    < /执行>
                < /处决>
            < /插件>
        < /插件>
...

我成功地用它与命令

  MVN安装

但是,当我尝试把它围成pluginManagement标签中,Maven的依赖,插件停止工作,当我启动安装目标。
为什么pluginManagement标签更改构建行为?或者,我应该使用的目标或选择?<​​/ P>

感谢您事先的任何帮助。


解决方案

您还需要添加

&LT;&插件GT;
    &LT;&插件GT;
        &LT;&的groupId GT; org.apache.maven.plugins&LT; /的groupId&GT;
        &LT;&的artifactId GT; Maven的依赖,插件&LT; / artifactId的&GT;
    &LT; /插件&GT;
&LT; /插件&GT;

在你的构建,因为 pluginManagement 只是和大家分享您所有的项目模块相同的插件配置的一种方式。

从Maven的文档:


  

pluginManagement :是沿边的插件见过的元素。插件管理包含了几乎相同的方式,插件元素除了而非配置插件这个特定的项目构建的信息,它的目的是配置项目构建,从这个继承。然而,这仅配置了在孩子们的插件元素中实际引用的插件。孩子们有充分的覆盖pluginManagement定义权。


This is a snippet of my pom file.

....
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>                        
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            ......
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
...

I use it successfully with the command

mvn install

But, when I try to enclose it into the "pluginManagement" tag, the maven-dependency-plugin stops to work when I launch the install goal. Why the "pluginManagement" tag change the build behavior ? Or should I use another goal or option ?

Thank you in advance for any help

解决方案

You still need to add

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
    </plugin>
</plugins>

in your build, because pluginManagement is only a way to share the same plugin configuration across all your project modules.

From Maven documentation:

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one. However, this only configures plugins that are actually referenced within the plugins element in the children. The children have every right to override pluginManagement definitions.

这篇关于Maven的:什么是pluginManagement?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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