Compile Java project with dependencies into single JAR file

To create one single JAR file that contains all required JAR dependencies, you will need to use maven-assembly-plugin to create a custom JAR bundle.

Here is an example usage of the plugin:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>MyProject</finalName>
<outputDirectory>${project.basedir}/../output</outputDirectory>
<descriptorRefs>jar-with-dependencies</descriptorRefs>
</configuration>
<executions>
<execution>
<id>build-jar-with-dependencies</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
Share Comments

Enforce Java version on Maven

In a Maven project for managing Java application, to enforce usage of a specific Java version, you will need to add configuration option to the maven-compiler-plugin.

To achieve this, simply add the appropriate source and target options to the maven-compiler-plugin, for example:

1
2
3
4
5
6
7
8
9
10
11
12
13
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

Change the source and target to the project’s appropriate Java version.

Share Comments

Fix Lets Encrypt renewal error on Ubuntu 16.04

Currently, there is one problem with cerificate renewal on Ubuntu 16.04 Xenial. Basically, the error will be similar to this,

Read More

Share Comments

Revert Git to a specific commit

Sometimes, you might want to revert to a specific commit because the commit tree looks ugly or some other reasons. To fix it, follow these steps:

Read More

Share

Fix abnormally slow in Mac OS X Finder

There is one problem when using Finder is that, it behaves pretty slow when opening, listing and traversing directories.

Read More

Share Comments