簡體   English   中英

如何僅對父模塊執行Maven插件?

[英]How do I execute maven plugin for parent module only?

因此,我創建了這個小maven插件,該插件將連接到數據庫服務器並創建項目所需的所有表。 問題是,該項目包含多個模塊,我希望在父模塊中定義該插件。 但是,它只需要執行一次,而不必為每個模塊單獨執行。 我認為在插件配置中添加"<inherited>false</inherited>"就足夠了,但是顯然不是。 這是我的父項目的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>rpg</groupId>
    <artifactId>rpg-build</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>rpg-build</name>

    <modules>
        <module>../rpg-web</module>
    <module>../rpg-service</module>
    <module>../rpg-commons</module>
    <module>../rpg-maven-plugin</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.2.9</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>rpg.maven.plugin</groupId>
                <artifactId>rpg-maven-plugin</artifactId>
                <version>0.0.1-SNAPSHOT</version>
                <inherited>false</inherited>
            </plugin>
        </plugins>
        <finalName>${artifactId}</finalName>
    </build>
</project>

在評論中回答:

您應該在插件的mojo中添加@aggregator批注。 – Andrew Logvinov 13年4月1日在12:40

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM