我在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?
答案 0 :(得分:9)
首先使用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
比你调用编译阶段double,只是简单地说:
mvn clean install
就足够了。我可以推荐阅读build life doc.