2
votes

I have 3 modules in my maven project for jar, war and ear package. When I build JAR file, I add some XML files to META-INF directory (like jboss.xml or ejb-jar.xml). If i build EAR, the package include jar file but without XML files in META-INF...

I'm confused because I don't know how to change it. Please help

2

2 Answers

3
votes

The simplest solution is to put the appropriate files into the src/main/application folder. In case of META-INF you can simply add this folder the src/main/application folder and after packaging the files will be packaged into the EAR file.

1
votes

sample maven project

  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>fun</groupId>
      <artifactId>fun</artifactId>
      <version>1.0</version>
      <packaging>ear</packaging>
      <build>
      <plugins>
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <finalName>MyEarFile</finalName>
            <version>5</version>
            <generatedDescriptorLocation>${basedir}/src/main/application/META-INF</generatedDescriptorLocation>
            <modules>
                <webModule>
                    <groupId>fun</groupId>
                    <artifactId>fun</artifactId>
                    <uri>fun.war</uri>
                    <bundleFileName>fun.war</bundleFileName>
                    <contextRoot>/fun</contextRoot>
                </webModule>
            </modules>
        </configuration>
    </plugin>           <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>
          </plugins>
          </build>

      <dependencies>

            <dependency>
                <groupId>fun</groupId>
                <artifactId>fun</artifactId>
                <version>1.0</version>
                <type>war</type>
            </dependency>
            </dependencies>
    </project>