Search code examples
javamavenmaven-3kotlinmaven-assembly-plugin

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


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?


Solution

  • 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.