Wednesday, 16 November 2011

How to change MANIFEST.MF generated by maven?

You have to add plugin configuration in pom.xml in section build/plugins:
Here is an example of configuring default class run when executing generated jar:
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
     <archive>
      <manifest>
       <mainClass>package.Class</mainClass>
      </manifest>
     </archive>
    </configuration>
   </plugin>
Here is an example of using already generated MANIFEST.MF file as the manifest file of the jar:
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
     <archive>
      <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
     </archive>
    </configuration>
   </plugin>

More info about plugin parameters on: http://maven.apache.org/maven-1.x/plugins/jar/manifest.html

No comments: