我有一个maven多模块项目,其中包含一个名为 mod1 的模块,我正在尝试使用{{1}添加到 /project jars
文件夹中来自应用程序文件夹,app pom.xml所在的位置。
错误:
mvn assembly:assembly
项目文件夹结构:
[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]
mod1 pom.xml
app
| pom.xml
| src | main | ...
wrapper
| pom.xml
| src | main | ...
mod1
| pom.xml
| src | main | ...
// After mvn assembly:assembly
project jars
| mod1.jar
wrapper pom.xml
<project>
<groupId>org.test</groupId>
<artifactId>mod1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
描述符(<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
更新
app pom.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>
答案 0 :(得分:1)
为什么要在项目中宣布应用程序&#39;两个模块&#39;包装&#39;和&#39; mod1&#39;。应用必须使用&#39; mod1&#39;在依赖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>
和<excludes>
创建assembly.xml并过滤依赖关系。
要创建装配,请使用以下答案: Maven build assembly with dependencies
答案 1 :(得分:0)
检查您的项目结构。在我的情况下,我用变量($)引用的目录名称不正确,目录被不同地调用,并产生此错误。我必须遵循父pom,遍历子和config.xml的错误。
答案 2 :(得分:0)
在我的情况下,工件具有版本,并且在最终捆绑的zip中没有预期,在修复了程序集的工件名称后,它就可以了。