Maven jar Plugin

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

Declaring a Main Class in JAR

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        ...
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>fully.qualified.MainClass</mainClass>
            </manifest>
          </archive>
        </configuration>
        ...
      </plugin>


Other Manifest Customization

Adding arbitrary manifest entries:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-jar-plugin</artifactId>
   <configuration>
      <archive>
         <manifest>
            <mainClass>io.novaordis.eventagent.EventAgent</mainClass>
               <manifestEntries>
                  <Premain-Class>io.novaordis.eventagent.EventAgent</Premain-Class>
                  <Agent-Class>io.novaordis.eventagent.EventAgent</Agent-Class>
                  <Can-Redefine-Classes>true</Can-Redefine-Classes>
                  <Can-Retransform-Classes>true</Can-Retransform-Classes>
               </manifestEntries>
          </manifest>
      </archive>
   </configuration>
</plugin>

In general, to use arbitrary manifest entries, use the following syntax:

...
<manifest>
   <manifestEntries>
      ...
      <key>value</key>
      ...
   </manifestEntries>
</manifest>