在Maven多模块项目中,是否可以递归地应用组装插件?

发布于 2024-09-25 09:31:33 字数 57 浏览 5 评论 0原文

我有一个多模块 Maven 项目,我想将通过在各个模块上运行组装插件创建的工件组装在一起。这可能吗?

I have a multi-module Maven project, and I would like to assemble together artifacts created by running the assembly plugin on individual modules. Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤者何惧 2024-10-02 09:31:33

是的,可以使用项目依赖项来执行此操作,可以在 Maven 组装插件

Yes it is possible to do so using the project dependencies which can read in detail on the documentation of the Maven Assembly Plugin.

花期渐远 2024-10-02 09:31:33

我想我已经通过在每个子模块的打包阶段运行程序集插件找到了我自己问题的答案。这保证了当我在顶级项目上运行程序集时,所有子模块都将被组装。

我的顶级 POM 中的插件配置如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<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.quantel</groupId>
    <artifactId>project-folders-modules</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>
    <description>Collection of modules for project folders. </description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <modules>
        <module>db-controller</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
        </plugins>
    </build>
</project>

I think I have found the answer to my own problem by running the assembly plugin during the package phase for each sub-module. This guarantees that when I run the assembly on the top level project, all sub-modules would have been assembled.

The plugin configuration in my top level POM looks like:

<?xml version="1.0" encoding="UTF-8"?>
<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.quantel</groupId>
    <artifactId>project-folders-modules</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>
    <description>Collection of modules for project folders. </description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <modules>
        <module>db-controller</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
        </plugins>
    </build>
</project>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文