Maven 程序集:错误输入中有多个文件
Maven Assembly: Error There is more than one file in input
我有一个构建 Ear 的 Maven 项目。然后,我们需要将耳朵与其他一些文件(shell 脚本等)打包成一个 zip 文件。
我的项目是这样的:
foo-parent
foo-jar
foo-sar
foo-ear
罐子、sar 和耳朵都生成了。 ear 包含来自其他子模块的 jar 和 sar。现在,我所要做的就是将那只耳朵与其他一些文件打包并压缩。
最初,我将程序集放在 foo-parent
中,但后来 运行 遇到了问题,即 foo-parent
是 运行 在构建 jar 之前的打包阶段,特区,和耳朵。仔细阅读,有人告诉我将程序集放在其中一个子模块中,所以我选择了 foo-ear
.
我现在收到错误:
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single
(foo-services-zip) on project foo-ear: Failed to create assembly:
Error creating assembly archive foo-services-dist: There is more
than one file in input.
我不确定 There is more than one file in input
是什么意思。
我的 foo-ear
POM 如下所示:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.vegicorp.foo</groupId>
<artifactId>foo-parent</artifactId>
<version>1.0.0</version>
<relativePath>..</relativePath>
</parent>
<artifactId>foo-ear</artifactId>
<packaging>ear</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
[...]
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>build-foo-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/foo-zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
[...]
</dependencies>
</project>
我的 src/assembly/foo-zip.xml
文件如下所示:
<assembly>
<id>foo-zip</id>
<formats>
<format>gzip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/dist-files</directory>
<outputDirectory></outputDirectory>
</fileSet>
</fileSets>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com.vegicorp.foo:foo-ear</include>
</includes>
<binaries>
<includeDependencies>false</includeDependencies>
<outputDirectory>data/ear-dir</outputDirectory>
<unpack>true</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
是的,我知道我可以只使用 <file>
或另一个 <fileSet>
,但是 ear 需要在 gzip 文件中解压,所以我需要使用 <moduleSets>
。我不确定 <binary>
或 <moduleSets>
是如何工作的,我相信我的错误是在那个配置的某个地方。
找到问题了。程序集文件的格式为 gzip
。这实际上是一种无效的格式,但大会仍然接受它。如果程序集中有多个文件,则程序集将失败。我将格式更改为 zip
并且一切正常 - 包括我认为是问题的模块内容。
这可能是 Assembly 插件中的错误。我得调查一下。
我有一个构建 Ear 的 Maven 项目。然后,我们需要将耳朵与其他一些文件(shell 脚本等)打包成一个 zip 文件。
我的项目是这样的:
foo-parent
foo-jar
foo-sar
foo-ear
罐子、sar 和耳朵都生成了。 ear 包含来自其他子模块的 jar 和 sar。现在,我所要做的就是将那只耳朵与其他一些文件打包并压缩。
最初,我将程序集放在 foo-parent
中,但后来 运行 遇到了问题,即 foo-parent
是 运行 在构建 jar 之前的打包阶段,特区,和耳朵。仔细阅读,有人告诉我将程序集放在其中一个子模块中,所以我选择了 foo-ear
.
我现在收到错误:
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single
(foo-services-zip) on project foo-ear: Failed to create assembly:
Error creating assembly archive foo-services-dist: There is more
than one file in input.
我不确定 There is more than one file in input
是什么意思。
我的 foo-ear
POM 如下所示:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.vegicorp.foo</groupId>
<artifactId>foo-parent</artifactId>
<version>1.0.0</version>
<relativePath>..</relativePath>
</parent>
<artifactId>foo-ear</artifactId>
<packaging>ear</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
[...]
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>build-foo-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/foo-zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
[...]
</dependencies>
</project>
我的 src/assembly/foo-zip.xml
文件如下所示:
<assembly>
<id>foo-zip</id>
<formats>
<format>gzip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/dist-files</directory>
<outputDirectory></outputDirectory>
</fileSet>
</fileSets>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com.vegicorp.foo:foo-ear</include>
</includes>
<binaries>
<includeDependencies>false</includeDependencies>
<outputDirectory>data/ear-dir</outputDirectory>
<unpack>true</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
是的,我知道我可以只使用 <file>
或另一个 <fileSet>
,但是 ear 需要在 gzip 文件中解压,所以我需要使用 <moduleSets>
。我不确定 <binary>
或 <moduleSets>
是如何工作的,我相信我的错误是在那个配置的某个地方。
找到问题了。程序集文件的格式为 gzip
。这实际上是一种无效的格式,但大会仍然接受它。如果程序集中有多个文件,则程序集将失败。我将格式更改为 zip
并且一切正常 - 包括我认为是问题的模块内容。
这可能是 Assembly 插件中的错误。我得调查一下。