创建多模块目录程序集失败

时间:2013-05-06 16:36:58

标签: java maven-3 maven-assembly-plugin

我有一个包含三个项目的多模块项目。我尝试将每个模块的src/main/config的内容复制到父项目目录中的target/benchmark/config

parent
    pom.xml (second setup)
    /src/main/assembly/benchmark.xml
    /module1
    /module2
    /module3
    /aggregationparent
        pom.xml (first setup)
        /src/main/assembly/benchmark.xml

src/assembly/benchmark.xml 下的父(汇总项目)中包含的程序集描述符

<formats>
    <format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
    <moduleSet>
        <includes>
            <include>groupid:artifactid</include>
        </includes>
        <sources>
            <fileSets>
                <fileSet>
                    <directory>src/main/config/*</directory>
                    <outputDirectory>config</outputDirectory>
                </fileSet>
            </fileSets>
        </sources>
    </moduleSet>
</moduleSets>

程序集插件调用

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <descriptor>src/main/assembly/benchmark.xml</descriptor>
                <finalName>benchmark</finalName>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

我尝试使用两个目录设置,这两个目录设置都失败并显示不同的错误消息:

  1. 父级位于通过../modulename引用其模块的单独目录中 结果是:

    Building artifactid 1.0-SNAPSHOT
    ------------------------------------------------------------------------
    
    [assembly:single]
    The following patterns were never triggered in this artifact inclusion filter:
    o  'groupid:artifactid'
    
    ------------------------------------------------------------------------
    BUILD FAILURE
    ------------------------------------------------------------------------
    Total time: 4.187s
    Finished at: Mon May 06 18:28:59 CEST 2013
    Final Memory: 8M/104M
    ------------------------------------------------------------------------
    Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (default-cli) on project projectname: Failed to create assembly: Error creating assembly archive benchmark: You must set at least one file. -> [Help 1]  
    

    这里我猜../moduledir引用导致错误导致程序集插件中无法解析的模块。这是正确的吗?我做错了什么?

  2. 父pom位于模块的父目录中 结果:

    Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project *moduleid*: Error reading assemblies: No assembly descriptors found. -> [Help 1]
    

    Debug输出显示程序集插件试图在每个所选模块的项目根目录中找到程序集描述符,而不是使用父项目中提供的那个?这是有意的吗?如何告诉它使用父母?

0 个答案:

没有答案