Maven Error读取程序集:未找到程序集描述符

时间:2015-03-26 15:28:37

标签: plugins maven-2 assemblies maven-assembly-plugin

关注this Guide我运行了命令

mvn assembly:assembly

并获得了Build Failure

Error reading assemblies: No assembly descriptors found.

我已经看过很多关于这方面的问题,但无济于事。

this post开始,我在里面创建了一个.xml

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>jar-with-dependencies</id>
    <formats>
        <format>jar</format>
    </formats>
    <dependencySets>
        <dependencySet>
            <scope>runtime</scope>
            <unpack>true</unpack>
            <unpackOptions>
                <excludes>
                    <exclude>**/LICENSE*</exclude>
                    <exclude>**/README*</exclude>
                </excludes>
            </unpackOptions>
        </dependencySet>
    </dependencySets>
    <fileSets>
        <fileSet>
            <directory>${project.build.outputDirectory}</directory>
            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>src/main/resources/META-INF/services</directory>
            <outputDirectory>META-INF/services</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

并将其包含在pom.xml

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-5</version>
    <configuration>
      <descriptors>
        <descriptor>jar-with-dependencies.xml</descriptor>
        </descriptors>
    </configuration>
  </plugin>

但仍然没有运气。

我对此很陌生,你可以告诉我,我该如何运行?

~~ EDIT ~~

pom.xml我改变了

<descriptor>jar-with-dependencies.xml</descriptor>

<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>

~~编辑2 ~~

pom.xml现在包含:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-5</version>
    <executions>
        <execution>
        <id>make-assembly</id>
        <phase>package</phase>
        <goals>
            <goal>single</goal>
        </goals>
        <configuration>
        <descriptors>
            <descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
        </descriptors>
        </configuration>
        </execution>
        </executions>
</plugin>

~~编辑3 ~~

pom.xml现在对我有用:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-5</version>
    <configuration>
        <descriptors>
            <descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
        </descriptors>
        </configuration>
    <executions>
        <execution>
        <id>make-assembly</id>
        <phase>package</phase>
        <goals>
            <goal>single</goal>
        </goals>
        </execution>
    </executions>
</plugin>

1 个答案:

答案 0 :(得分:7)

为此,您需要在jar-with-dependencies.xml和此XML中创建文件src/main/assembly/

<descriptors>
    <descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>

即。您需要指定文件的路径,惯例是将文件放入src/main/assembly/

要使用Maven提供的内容,您需要使用descriptorRef元素(包含在descriptorRefs中)。

另外,不要将描述符放在execution元素内,或者mvn assembly:assembly再也找不到它(因为你专门将它移到了mvn package目标)。

[编辑] 我自己也按照教程进行操作,您可能错过了一个重点:您需要选择正确的原型。就我而言,那是5,但订单可以改变。因此,请阅读整个列表并查找字符串openimaj-quickstart-archetype,否则事情就会中断。