views:

388

answers:

2

I am pretty new to maven.

Is there any plugin or packaging type suitable for building application client jar file ?

I want to add the application-client.xml file to the META-INF folder inside the jar.

The normal jar packaging doesn't include the file.

A: 

I'm not very familiar with the JavaEE support in Maven, but it looks like the ejb plugin can generate a client jar as well if configured properly. Check this page out:

Maven EJB Plugin - Generating an EJB client

Mike Deck
Thanks. I tried it but doesn't seem to work. The application-client.xml is not included. Should I change the packaging ?
rangalo
This just creates a 2nd artifact, with the client classes (eg. EJB interfaces) for inclusion in client applications. These client applications could be WAR modules, or other application clients. The 2nd artifact has the "-classes" maven classifier.
Brian Leathem
+1  A: 

You should only need to define the project with jar packaging (and as it is the default you don't need to declare it). If you define the application-client.xml in the src/main/resources/META-INF folder it will be included in the META-INF folder of the final jar.


To define additional information you need to configure the jar plugin as below.

<project>
...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.mycompany.app.App</mainClass>
              <addClasspath>true</addClasspath>
            </manifest>
            <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

Check out the guide to working with manifests for full details

Rich Seller
It works well. Now how to add main class and classpath information to menifest ?
rangalo