Creating JAR with dependencies using maven (eclipse, others)

Source: http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven

 

Inside pom.xml use the following XML code

<?xml version="1.0" encoding="utf-8"?>
<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>fully.qualified.MainClass</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
    </plugin>
  </plugins>
</build>

 

 

To build the JAR use the following command

$ mvn clean compile assembly:single

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *