Maven jar Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 41: Line 41:
         <manifest>
         <manifest>
             <mainClass>io.novaordis.eventagent.EventAgent</mainClass>
             <mainClass>io.novaordis.eventagent.EventAgent</mainClass>
              <manifestEntries>
        </manifest>
                  <Premain-Class>io.novaordis.eventagent.EventAgent</Premain-Class>
        <manifestEntries>
                  <Agent-Class>io.novaordis.eventagent.EventAgent</Agent-Class>
            <Premain-Class>io.novaordis.eventagent.EventAgent</Premain-Class>
                  <Can-Redefine-Classes>true</Can-Redefine-Classes>
            <Agent-Class>io.novaordis.eventagent.EventAgent</Agent-Class>
                  <Can-Retransform-Classes>true</Can-Retransform-Classes>
            <Can-Redefine-Classes>true</Can-Redefine-Classes>
              </manifestEntries>
            <Can-Retransform-Classes>true</Can-Retransform-Classes>
          </manifest>
        </manifestEntries>
       </archive>
       </archive>
   </configuration>
   </configuration>
Line 58: Line 58:
...
...
<manifest>
<manifest>
  <manifestEntries>
      ...
      <key>value</key>
      ...
  </manifestEntries>
</manifest>
</manifest>
<manifestEntries>
  ...
  <key>value</key>
  ...
</manifestEntries>
</pre>
</pre>

Revision as of 21:56, 9 May 2016

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>
         </manifest>
         <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>
      </archive>
   </configuration>
</plugin>

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

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