0

I want to create an EAR using Maven, but since I'm in a pure Tycho world, I can't use the maven-ear-plugin, just the maven-assembly-plugin (which is fine).

There are multiple questions even on this very site that indicate that the maven-assembly-plugin can build EARs, even though the documentation says no.

However, when I use define the EAR format like this:

<formats>
    <format>ear</format>
</formats>

I get the following exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.0:single (make-assembly) on project org.acme.application: Failed to create assembly: Error creating assembly archive default: appxml attribute is required -> [Help 1]

(I tried a couple of versions for the maven-assembly-plugin, so it's not that.)

Since a EAR is just a renamed JAR, I'm now using the JAR format and this other Maven plug-in:

<plugin>
    <groupId>com.coderplus.maven.plugins</groupId>
    <artifactId>copy-rename-maven-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <id>rename-ear</id>
            <phase>verify</phase>
            <goals>
                <goal>rename</goal>
            </goals>
            <configuration>
                <sourceFile>${basedir}/target/${earName}.jar</sourceFile>
                <destinationFile>${basedir}/target/${earName}.ear</destinationFile>
            </configuration>
        </execution>
    </executions>
</plugin>

Which works nicely in creating an EAR, however with mvn install it brings the following exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-install) on project org.acme.application: Failed to install artifact group:org.acme.application:jar:1.9.126-SNAPSHOT: C:\workspace\Application\target\Application.jar (Das System kann die angegebene Datei nicht finden) -> [Help 1]

(It's German for "Cannot find file", one day I'll get him to print out readable error messages.)

Of course, now I could copy the JAR to an EAR instead of just renaming it, but I thought I get a 2nd oppinion first: Is it possible to create an EAR with the maven-assembly-plugin? If so, how?

Stefan S.
  • 3,950
  • 5
  • 25
  • 77
  • Use the packaging type `ear` and define the dependencies in the ear module on the jar's and that will work also for OSGi...Apart from that make an simple example project which has 2-3 module (OSGi) put that on Github so we can have a look at it... – khmarbaise May 26 '17 at 08:00
  • @khmarbaise I can't use that packing type, because the EAR is build out of the contents of a feature (the packaging type is `eclipse-feature`). – Stefan S. May 26 '17 at 08:21
  • I know but you can add the resulting jar file as a jar module in EAR configuration... – khmarbaise May 26 '17 at 08:49
  • @khmarbaise Nope, because that would need a Maven depedency. I can only copy the files out of other project's _targets/_ folders. – Stefan S. May 29 '17 at 09:30

0 Answers0