javamavenearmaven-ear-plugin

maven-ear-plugin <packagingIncludes> not including project files


My ear project has the following structure:

enter image description here

And my pom.xml goes like this:

  <plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.10</version>
    <configuration>
      <earSourceIncludes>META-INF/*</earSourceIncludes>
      <packagingIncludes>META-INF/*,**/*.war</packagingIncludes>
      <version>7</version>
                <modules>
                    <webModule>
                        <groupId>com.ex</groupId>
                        <artifactId>one</artifactId>
                    </webModule>
                </modules>
      <generateApplicationXml>false</generateApplicationXml>  
    </configuration>
  </plugin>

What I want is to include in my ear file the contents of the folder META-INF, in a similar folder in the root of the ear file called META-INF.

I've tried multiple combinations with earSourceIncludes and packagingIncludes with no success: My ear file has the linked application .war, which is good, and a META-INF folder which doesn't have what I need, but a pregenerated MANIFEST.MF file and a maven folder with the pom instead.

I wonder if I need the earSourceIncludes at all. To be honest, I don't know why it didn't work with just the packagingIncludes parameter.


Solution

  • You could use the maven-resource-plugin to include the content of META-INF folder to root META-INF folder. See below.

    Let

    Project base directory - ${project.basedir}

    EAR root directory - ${project.rootdir}

    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <executions>
            <execution>
                <id>copy-resources</id>
                <!-- here the phase you need -->
                <phase>validate</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>                         
                    <outputDirectory>${project.build.directory}/${project.build.finalName}/META-INF</outputDirectory>
                    <resources>
                        <resource>                      
                            <directory>${project.basedir}/META-INF</directory>
                            <filtering>true</filtering>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>