为什么我会得到“未找到程序集描述符".建立这个专案时发生错误? [英] Why do I get "No assembly descriptors found." error while building this project?

查看:112
本文介绍了为什么我会得到“未找到程序集描述符".建立这个专案时发生错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些用Kotlin编写的项目.当我运行clean compile assembly:single install时,出现以下错误消息:

I have a little project written in Kotlin. When I run clean compile assembly:single install, I get following error message:

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位于 pom.xml 像这样:

My jar-with-dependencies.xml is located in src/main/assembly and referenced in pom.xml like this:

<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?

But I still get the error. How can I correct my project in order to be able to package it as jar with dependencies?

推荐答案

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

First use an uptodate version of maven-assembly-plugin and not an ancient version...Furthermore you should call it via mvn clean package cause you bound the maven-assembly-plugin to the package life cycle phase...if you try to do mvn ... assembly:single you are not calling the life cycle...Apart from that you would like to use jar-with-dependencies descriptor than you should do that like this:

<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:

Apart from that if you call Maven like this:

mvn clean compile assembly:single install

比您将编译阶段调用两次,导致的原因仅仅是:

Than you calling the compile phase double, cause just simply a:

mvn clean install 

就足够了.我可以建议阅读构建生命文档.

is sufficient. I can recommend to read the build life doc.

这篇关于为什么我会得到“未找到程序集描述符".建立这个专案时发生错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆