Home » Java » java – maven plug-ins specified in pom.xml don't execute-Exceptionshub

java – maven plug-ins specified in pom.xml don't execute-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment


I’m building my Java project and have specified 2 maven plug-ins, maven-jar-plugin and maven-dependency-plugin. I execute mvn clean package from the command line. The source code is compiled successfully; however, I never see the dependency plugin executing. In addition, when doing mvn –debug clean package I don’t see the jar-plugin executing with my specified parameters.

I’m looking for some assistance as to why these plugins are not running when doing mvn clean package.

A snippet of the pom.xml:

FYI, I did not include all of the dependencies and the groupId, main class information was changed to protect the innocent. However, the structure of the pom.xml is intact.

`<?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">




    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
                <!-- <overWriteIfNewer>true</overWriteIfNewer> -->
                <useBaseVersion>false</useBaseVersion> -->
How to&Answers:

Both plugins are defined in <pluginManagement>. pluginManagement is used to define plugin versions and configuration. It does not add the plugins to the lifecycle. You need to define the dependency plugin in <plugins> as well (outside pluginManagement).

The Maven Jar Plugin is actually implicitly included in the lifecycle, but as you do not configure the plugin itself but an execution of the plugin, the values never have any effect.


I was able to resolve this issue. I removed the plugins out from under the stanza. In addition, for the jar-plugin I removed the and stanzas. With these removed the jar was created properly and the manifest file was generated properly.