Maven

Building a JAR with dependencies

<build>
      <plugins>
              <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-dependency-plugin</artifactId>
                      <executions>
                              <execution>
                                      <id>copy-dependencies</id>
                                      <phase>prepare-package</phase>
                                      <goals>
                                              <goal>copy-dependencies</goal>
                                      </goals>
                                      <configuration>
                                              <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                              <overWriteReleases>false</overWriteReleases>
                                              <overWriteSnapshots>false</overWriteSnapshots>
                                              <overWriteIfNewer>true</overWriteIfNewer>
                                      </configuration>
                              </execution>
                      </executions>
              </plugin>
              <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-jar-plugin</artifactId>
                      <configuration>
                              <archive>       
                                      <manifest>              
                                              <addClasspath>true</addClasspath>
                                              <classpathPrefix>lib/</classpathPrefix>
                                              <mainClass>full.path.to.MainClass</mainClass>
                                      </manifest>
                              </archive>
                      </configuration>
              </plugin>
      </plugins>
</build>