【问题标题】:Why do I get "No assembly descriptors found." error while building this project?为什么我会收到“未找到程序集描述符”。构建此项目时出错?
【发布时间】:2016-07-17 13:24:55
【问题描述】:

我有一点用 Kotlin 写的 project。当我运行clean compile assembly:single install 时,我收到以下错误消息:

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

我的jar-with-dependencies.xml 位于src/main/assembly 并在pom.xml 中引用,如下所示:

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

但我仍然收到错误消息。如何更正我的项目以便能够将其打包为具有依赖项的 jar?

【问题讨论】:

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


    【解决方案1】:

    首先使用maven-assembly-plugin 的最新版本而不是旧版本...此外,您应该通过mvn clean package 调用它,因为您将maven-assembly-plugin 绑定到package 生命周期阶段...如果你尝试做mvn ... assembly:single 你没有调用生命周期...除此之外你想使用jar-with-dependencies 描述符而不是你应该这样做:

    <project>
      [...]
      <build>
        [...]
        <plugins>
          <plugin>
            <!-- NOTE: We don't need a groupId specification because the group is
                 org.apache.maven.plugins ...which is assumed by default.
             -->
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
            </configuration>
            [...]
    </project>
    

    除此之外,如果你这样调用 Maven:

    mvn clean compile assembly:single install
    

    比你调用编译阶段加倍,原因只是一个:

    mvn clean install 
    

    就足够了。我可以推荐阅读build life doc.

    【讨论】:

    • 这非常有用。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2015-05-30
    • 2016-08-26
    • 2020-10-05
    • 1970-01-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多