I have a Maven project that builds an Ear. We then need to package that ear up into a zip file with a few other files (shell scripts, etc.).
My project looks like this:
foo-parent
foo-jar
foo-sar
foo-ear
The jar, sar, and ears all build. The ear contains the jar and the sar that from the other submodules. Now, all I have to do is package that ear with a few other files and zip it up.
Originally, I put the assembly in foo-parent
, but then ran into the problem that foo-parent
was running the package phase on itself before building the jar, sar, and ear. Reading up a bit, I was told to put the assembly in one of the submodules, so I picked foo-ear
.
I am now getting the error:
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.
I am not sure what There is more than one file in input
means.
My foo-ear
POM looks like this:
<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>
My src/assembly/foo-zip.xml
file looks like this:
<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>
Yes, I know I could use just <file>
or another <fileSet>
, but the ear needs to be unpacked inside of the gzip file, so I need to use <moduleSets>
. I am not sure understand how <binary>
or how <moduleSets>
works, and I believe my error is somewhere in that configuration.
Found the problem. The assembly file had a format of gzip
. This is actually an invalid format, but the Assembly still takes it. If you have more than a single file in your assembly, the assembly will fail. I changed the format to zip
and everything works -- including the module stuff which I thought was the issue.
This maybe a bug in the Assembly plugin. I'll have to investigate.