pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>mavenUberJarWithDependencies</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<properties>
   <java.version>1.8</java.version>
</properties>
<!-- alternatively
<configuration>
 <source>1.8</source>
 <target>1.8</target>
</configuration>
-->
<dependencies>
  <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.4</version>
  </dependency>
</dependencies>
<build>
  <plugins>
    <plugin>
      <!-- Collect all the dependencies in lib/ for inclusion in ├╝ber JAR -->
      <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>
      <!-- Build an executable JAR -->
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>3.0.2</version>
      <configuration>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <!-- Make the collected dependencies available in the lib dir >
            <classpathPrefix>lib/</classpathPrefix>
            <mainClass>Test</mainClass>
          </manifest>
        </archive>
      </configuration>
    </plugin>
    <plugin>
      <!-- Build an executable JAR -->
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <executions>
        <execution>
          <id>default-testCompile</id>
          <phase>test-compile</phase>
          <goals>
             <goal>testCompile</goal>
          </goals>
          <configuration>
            <compilerVersion>${java.version}</compilerVersion>
            <source>${java.version}</source>
            <target>${java.version}</target>
          </configuration>
        </execution>
        <execution>
          <id>default-compile</id>
          <phase>compile</phase>
          <goals>
            <goal>compile</goal>
          </goals>
          <configuration>
            <compilerVersion>${java.version}</compilerVersion>
            <source>${java.version}</source>
            <target>${java.version}</target>
          </configuration>
        </execution>
      </executions>
      <configuration>
         <compilerVersion>${java.version}</compilerVersion>
         <source>${java.version}</source>
         <target>${java.version}</target>
      </configuration>
    </plugin>
  </plugins>
</build>
</project>