简体   繁体   中英

Inherit build plugin/extension/… in Maven

Say a Maven project has a cool build plugin configured:

<project>
    ...
    <build>
       ... extensions etc.
    </build>
    ...
</project>

I want this configuration to be reusable, so that I can run the goals provided by the plugins/extensions in any new project. The above project might exist just so that other projects can reuse the config.

What is the best way to achieve this?

Use a parent.pom . Deploy this pom to your local repository. Of course you could configure parent.pom s for each type of project that you regularly develop in your organisation. Probably a master.pom with general values (location of servers, organisation name, general code style...) is a good idea. The project specific pom s would use this as parent.

Declare this pom.xml as of type pom :

<type>pom</type>

and declare it as a parent in every "child" pom.xml that needs the configured plugins: http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Inheritance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM