We will see an example on how to remove default jar by maven build. Generally this may be required in a situation where you are generating executable jar or executable jars and your application does not require additional non-executable jar generated by maven build. Then you can remove such jar from target folder.


Apache Maven 3.6.0, Java 1.8


We have seen in our previous example how to generate single executable jar file or multiple executable jar files.

But if you had noticed carefully you saw there was an additional jar was created in the target folder and this jar was created by maven. By default maven uses maven-jar-plugin to generate jar file.

To prevent maven tool from generating such default jar we need to override the maven-jar-plugin.

You need to add this additional plugin in the plugin section along with maven-assembly-plugin.

The example may be given in the below pom.xml file:

<project xmlns="" xmlns:xsi=""
    <name>executable jar</name>

Thanks for reading.


Leave a Reply

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