如何使用 maven-assembly-plugin 更改 moduleSet/sources 的输出目录

How to change output directory of moduleSet/sources with maven-assembly-plugin

我想更改moduleSet with maven-assemble-plugin的输出目录。我试过 moduleSet/sources/outputDirectory,但我得到了一个奇怪的 zip 文件。

我的描述符:

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">

    <id>distribution</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>

    <moduleSets>
        <moduleSet>
            <useAllReactorProjects>true</useAllReactorProjects>
            <excludes>
                <exclude>*:test-distribution</exclude>
            </excludes>
            <sources>
                <includeModuleDirectory>false</includeModuleDirectory>
                <outputDirectory>sources</outputDirectory>
                <fileSets>
                    <fileSet>
                        <includes>
                            <include>src/**</include>
                        </includes>
                    </fileSet>
                </fileSets>
            </sources>
        </moduleSet>
    </moduleSets>
</assembly>

我的 zip 文件具有以下结构:

- test-distribution.zip
    - sources
        - src
             - main
             - test
        - target
        - pom.xml  (of first module)
    - src
        - main
        - test

/sources 下是孔项目,而不仅仅是 src 文件夹,/src 下是源文件夹。

我想要的是:

- test-distribution.zip
    - sources
         - main
         - test

如何更改 moduleSet/sources 的目录名称?

使用 fileSet/outputDirectory and fileSet/directory 可以更改源目录的名称:

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">

    <id>distribution</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>

    <moduleSets>
        <moduleSet>
            <useAllReactorProjects>true</useAllReactorProjects>
            <excludes>
                <exclude>*:test-distribution</exclude>
            </excludes>
            <sources>
                <includeModuleDirectory>false</includeModuleDirectory>
                <fileSets>
                    <fileSet>
                        <includes>
                            <include>/**</include>
                        </includes>
                        <outputDirectory>sources</outputDirectory>
                        <directory>src</directory>
                    </fileSet>
                </fileSets>
            </sources>
        </moduleSet>
    </moduleSets>
</assembly>

但我不能说,sources/outputDirectory 应该做什么。这个选项很奇怪。