English 中文(简体)
Maven s pom.xml的原始管理是什么?
原标题:What is pluginManagement in Maven s pom.xml?

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>
...

我在指挥部门成功使用。

mvn install

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

最佳回答

您仍然需要补充。

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

由于<代码>pluginManagement是在所有项目单元中分享相同的原始组合的唯一途径。

摘自Maven文件:

pluginManagement:这是一面皮条块的元素。 原始管理包含一些原始内容,但并非为这一特定项目建筑整理原始信息,而是打算混淆该项目的建筑。 然而,这只是混杂在儿童原始要素中实际参考的gin果。 儿童有权超越原始管理定义。

问题回答

The difference between <pluginManagement/> and <plugins/> is that a <plugin/> under:

  • <代码><pluginManagement/>界定了在你的建筑中将由模块继承的原始产品的环境。 对于你有母异构体的病例来说,这非常大,并且要避免复制这些模块中每个单元的原体组合相同的代码。

  • <plugins/> is a section for the actual invocation of the plugins. It may or may not be inherited from a <pluginManagement/>.

如果没有母体POM,你就不需要在项目上安装<代码>和>;。 然而,如果是父母的 p,那么在孩子的 p子中,你需要声明如下:

<plugins>
    <plugin>
        <groupId>com.foo</groupId>
        <artifactId>bar-plugin</artifactId>
    </plugin>
</plugins>

通知你如何界定任何组合。 如果你需要根据儿童项目的需要进一步调整其职业,那么你可以继承该职务。

For more specific information, you can check:

请注意:pluginManagement in a oul pom to configure it in case any child pom Sees to use it, but not each child plugin have wishs to use it. 例如,super pom界定了madoc plugin的一些选择。

Not each child pom might want to use Javadoc, so you define those defaults in a pluginManagement section. The child pom that wants to use the Javadoc plugin, just defines a plugin section and will inherit the configuration from the pluginManagement definition in the parent pom.

<pluginManagement> just like <dependencyManagement> are both used to share only the configuration between a parent and it s sub-modules.

为此,我们界定了母子项目中的依赖和原始共同组合,然后,我们只必须宣布子模块中的依赖/pl使用,而不必为其确定一个组合(即版本或执行、目标等)。 虽然这并不妨碍我们超越分层的组合。

相比之下,<代码><dependencies>和<plugins>与它们的组合并存,不应在次模块中重新列报,否则将发生冲突。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签