gpt4 book ai didi

java - 创建程序集存档 bin : You must set at least one file 时出错

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:35:43 35 4
gpt4 key购买 nike

我有一个 Maven 多模块项目,其中包含一个名为 mod1 的模块,我正试图将其添加到文件夹 /project jars使用应用程序文件夹中的 mvn assembly:assembly,应用程序 pom.xml 所在的位置。

错误:

[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

<project>
<groupId>org.test</groupId>
<artifactId>mod1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>

包装器 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>

更新

应用 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”中声明两个模块“wrapper”和“mod1”。应用程序必须在依赖库中使用“mod1”吗?

这样做:

Add parent pom.xml and 3 modules :
+app
+wrapper
+mod1

pom 应用程序:

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

创建 assembly.xml 并使用 <includes> 过滤依赖性和 <excludes> .

要创建程序集,请使用以下答案: Maven build assembly with dependencies

关于java - 创建程序集存档 bin : You must set at least one file 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33852914/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com