Maven tutorial (22) - Maven plugins and the pluginManagement

Original Address https://blog.csdn.net/liupeifeng3514/article/details/80236827

pluginManagement difference plugins and an overview of
the difference between plugins and pluginManagement, the difference dependencies and dependencyManagement and we've studied is very similar. plugin in the plugins used to be true, but under the plugins in the plugin pluginManagement is merely a statement of the plugin can subprojects under pluginManagement selection information, inheritance, and other coverage.

pluginManagement actual use
if the two projects exist, project A is the parent of the item B, the relationship determined by the relationship pom file. A file fragment pom parent item as follows:

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <attach>true</attach>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</pluginManagement>

If the project B also wants to use the plugin configuration, you need only the following sub-pom configuration file in Project B:

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

We can see that the child pom file, eliminating the need for version information, and other configuration details, only need to specify groupId and artifactId, other information is inherited from the parent pom file. Of course, if the sub-pom file you want to customize their specific content, it may be provided separately, and will cover inherited from the parent pom file to the content.

Note that, dependencies and dependencyManagement are direct child element under project, but plugins and pluginManagement is a direct child elements build the next project.
----------------
Disclaimer: This article is CSDN blogger original article "B8613A" and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/liupeifeng3514/article/details/80236827

 

Guess you like

Origin www.cnblogs.com/dyh004/p/11579931.html