R – maven javaee application client plugin

application-clientjakarta-eemaven-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.

Best Answer

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