如何从父模块访问Maven子模块中的插件

问题描述

我有一个Maven多模块设置,其中在子模块中定义的配置文件包括fabric8插件,如果该配置文件处于活动状态,则可以构建Docker映像,请参见下文

根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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>root</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>control</name>
    <packaging>pom</packaging>

    <modules>
        <module>parent</module>
        <module>docker</module>
        <module>...</module>
        <module>...</module>
        <module>...</module>
    </modules>
</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>com.mycompany</groupId>
    <artifactId>docker</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <profiles>
        <profile>
            <id>Docker</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>0.34.1</version>
                        <dependencies>
                            <dependency>
                                <groupId>com.amazonaws</groupId>
                                <artifactId>aws-java-sdk-core</artifactId>
                                <version>${aws.version}</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <registry>${aws.ecr.registry}</registry>
                            <images>
                                <image>
                                    <name>${aws.ecr.registry}/${aws.ecr.repository}:${project.artifactId}-${project.version}</name>
                                    <build>
                                        <contextDir>${project.build.directory}/docker.tmp/</contextDir>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>docker-build</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>docker-push</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

运行正常的构建,即mvn clean install -PDocker已成功完成,但是如果我直接从父模块调用docker目标之一,例如mvn -PDocker docker:help失败,并显示错误

No plugin found for prefix 'docker' in the current project and in the plugin groups 

从docker目录运行同一命令成功完成。

需要进行哪些更改,以便命令在根目录中成功完成?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...