Why do I get “No assembly descriptors found.” error while building this project?

故事扮演 提交于 2021-02-20 01:19:40

问题


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]

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>

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


回答1:


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>

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.



来源:https://stackoverflow.com/questions/36293625/why-do-i-get-no-assembly-descriptors-found-error-while-building-this-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!