maven create executable jar with dependency

was trying to use intellij built in jar builder with my standalone executable jar. but seems something wrong with it.

Had to use mvn for it . below are the steps:

Herewe use maven-shade-plugin, in Pom.xml:

<build>
   <plugins>
     <plugin>
         <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>2.3.1</version>
               <configuration>
                  <source>1.6</source>
                   <target>1.6</target>
               </configuration>
     </plugin>
  <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
    <execution>
      <phase>package</phase>
      <goals>
            <goal>shade</goal>
       </goals>
    </execution>
</executions>
<configuration>
        <finalName>uber-${artifactId}-${version}</finalName>
        <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                          <mainClass>org.finra.cdip.luceneInfinispanMgrt.Executor</mainClass>
              </transformer>
          </transformers
    </configuration>
  </plugin>
 </plugins>
</build>

run : mvn clean package

we can get the jar file in the target folder.

The Manifest.MF file specifies the main class by using:

Main-Class: MyMainClassName

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s