maven 报错 Failed to create assembly: archive cannot be empty

柔情只为你懂 2022-10-17 04:14 364阅读 0赞

背景:

pom.xml 里面 plugin 的配置如下:

  1. <plugin>
  2. <groupId>org.apache.maven.plugins</groupId>
  3. <artifactId>maven-assembly-plugin</artifactId>
  4. <version>3.1.1</version>
  5. <configuration>
  6. <finalName>${project.artifactId}</finalName>
  7. <appendAssemblyId>true</appendAssemblyId>
  8. <descriptors>
  9. <descriptor>src/main/assembly/client-jar.xml</descriptor>
  10. </descriptors>
  11. </configuration>
  12. <executions>
  13. <execution>
  14. <id>make-assembly</id>
  15. <phase>package</phase>
  16. <goals>
  17. <goal>single</goal>
  18. </goals>
  19. </execution>
  20. </executions>
  21. </plugin>

src/main/assembly/client-jar.xml 配置如下:

  1. <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  4. <id>client</id>
  5. <formats>
  6. <format>jar</format>
  7. </formats>
  8. <includeBaseDirectory>false</includeBaseDirectory>
  9. <fileSets>
  10. <fileSet>
  11. <directory>target/classes</directory>
  12. <includes>
  13. <include>**/embedclient/**</include>
  14. <include>**/model/**</include>
  15. </includes>
  16. <outputDirectory>${file.separator}</outputDirectory>
  17. </fileSet>
  18. </fileSets>
  19. </assembly>

执行命令 mvn assembly:single 的时候出现下面错误:

  1. [INFO] Scanning for projects...
  2. [WARNING] Failed to build parent project for xxx.xxxx.xxx:xxx:war:0.0.1
  3. [INFO]
  4. [INFO] ------------------< xxx.xxxx.xxx:xxx >-------------------
  5. [INFO] Building xxx Maven Webapp 0.0.1-SNAPSHOT
  6. [INFO] --------------------------------[ war ]---------------------------------
  7. [INFO]
  8. [INFO] --- maven-assembly-plugin:3.1.1:single (default-cli) @ xxx ---
  9. [INFO] Reading assembly descriptor: src/main/assembly/client-jar.xml
  10. [INFO] ------------------------------------------------------------------------
  11. [INFO] BUILD FAILURE
  12. [INFO] ------------------------------------------------------------------------
  13. [INFO] Total time: 1.430 s
  14. [INFO] Finished at: 2021-06-01T14:45:20+08:00
  15. [INFO] ------------------------------------------------------------------------
  16. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.1.1:single (default-cli) on project xxx: Failed to creat
  17. e assembly: Error creating assembly archive client: archive cannot be empty -> [Help 1]
  18. [ERROR]
  19. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  20. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  21. [ERROR]
  22. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  23. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

在网上收了半天没有发现有 archive cannot be empty 相关错误, 后面想着 存档不能为空 是不是没有相关 class 文件的原因,先执行一下 clean 和 compile,再执行 assembly 就好了,具体命令:

  1. mvn clean
  2. mvn compile
  3. mvn assembly:single

发表评论

表情:
评论列表 (有 0 条评论,364人围观)

还没有评论,来说两句吧...

相关阅读