创建程序集归档文件箱时出错:您必须至少设置一个文件 [英] Error creating assembly archive bin: You must set at least one file
问题描述
我有一个maven多模块项目,其中包含一个名为 mod1 的模块,我正在尝试将其添加到文件夹 / project jars
,带有 mvn assembly:assembly
来自应用程序文件夹,其中app是pom.xml。
I have a maven multi-module project with a module called mod1 that I'm trying to add into a folder /project jars
with mvn assembly:assembly
from the app folder, where the app pom.xml is.
错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.3:single (assembly) on project wrapper: Failed to create assembly
: Error creating assembly archive bin: You must set at least one file. -> [Help 1]
项目文件夹结构:
app
| pom.xml
| src | main | ...
wrapper
| pom.xml
| src | main | ...
mod1
| pom.xml
| src | main | ...
// After mvn assembly:assembly
project jars
| mod1.jar
mod1 pom.xml
mod1 pom.xml
<project>
<groupId>org.test</groupId>
<artifactId>mod1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
包装器pom.xml
wrapper pom.xml
<groupId>org.test.app</groupId>
<artifactId>wrapper</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/modules-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
描述符( src / main / assembly / modules-assembly.xml
):
<assembly>
<id>bin</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>org.test:mod1.jar</include>
</includes>
<binaries>
<attachmentClassifier>jar-with-dependencies</attachmentClassifier>
<outputDirectory>/project jars</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
更新
app pom.xml
app pom.xml
<project>
<groupId>org.test</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>../mod1</module>
<module>../wrapper</module>
</modules>
</project>
推荐答案
为什么要在项目'app'中声明两者模块'包装'和'mod1'。 app必须在依赖库中使用'mod1'吗?
Why you declare in the project 'app' the both modules 'wrapper' and 'mod1'. app must use 'mod1' at dependency lib?
执行此操作:
Add parent pom.xml and 3 modules :
+app
+wrapper
+mod1
pom app:
<dependency>
<groupId>${groupId}</groupId>
<artifactId>mod1</artifactId>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>project/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
使用< includes> $创建assembly.xml和过滤依赖项c $ c>和
<排除>
。
要创建程序集,请使用以下答案:
Maven构建具有依赖关系的程序集
To create the assembly, use this answer : Maven build assembly with dependencies
这篇关于创建程序集归档文件箱时出错:您必须至少设置一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!