简体   繁体   中英

In a Maven multi-modules project, is it possible to apply the assembly plug-in in a recursive manner?

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?

是的,可以使用项目依赖关系来做到这一点,该依赖关系可以在Maven Assembly Plugin的文档中详细阅读。

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>

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