简体   繁体   English

如何仅对父模块执行Maven插件?

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

So I created this small maven plugin, that would connect to the database server and create all the tables I need for the project. 因此,我创建了这个小maven插件,该插件将连接到数据库服务器并创建项目所需的所有表。 Thing is, that the project consists of multiple modules and I want the plugin to be defined in the parent one. 问题是,该项目包含多个模块,我希望在父模块中定义该插件。 Yet it needs to be executed only once, not separately for each module. 但是,它只需要执行一次,而不必为每个模块单独执行。 I thought that adding "<inherited>false</inherited>" to the plugin configuration would be enough, but apparently it's not. 我认为在插件配置中添加"<inherited>false</inherited>"就足够了,但是显然不是。 Here's the pom of my parent project: 这是我的父项目的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>

Answered in comments: 在评论中回答:

You should add @aggregator annotation to your plugin's mojo. 您应该在插件的mojo中添加@aggregator批注。 – Andrew Logvinov Apr 1 '13 at 12:40 – Andrew Logvinov 13年4月1日在12:40

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用插件前缀从命令行执行特定版本的 Maven 插件目标? - How do I execute a specific version of Maven plugin goal from command line using plugin prefix? 如何使用versions-maven-plugin更新非模块的父级? - How can I update the parent of a non-module with versions-maven-plugin? 如何执行maven插件_after_所有模块构建完成 - How to execute maven plugin _after_ all module builds finish 仅在父级中运行maven插件 - Running a maven plugin only in the parent 在孩子中执行 maven 插件,而不是孙辈或父母 - Execute maven plugin in children, not grandchildren or parent 如何仅使用自定义命令执行 Maven 插件? - How to execute a maven-plugin only with custom command? 我如何解决这个 mvn 安装错误? 无法执行 rpm-maven-plugin - How do i fix this mvn install error? Failed to execute rpm-maven-plugin 我如何配置Maven WAR插件以默认执行“就地”目标? - How do I configure the Maven WAR plugin to execute the “inplace” goal by default? 我怎样才能让 Maven 模块只运行到父级部署的测试阶段? - How can I make a Maven module only go until the test phase when the parent gets deployed? 如何只为多模块项目中的特定模块生成依赖树 - MAVEN - How do I generate dependency tree only for the specific module in a multi module project - MAVEN
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM