Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven shade plugin adding dependency-reduced-pom.xml to base directory

The maven shade plugin is creating a file called dependency-reduced-pom.xml and also artifactname-shaded.jar and placing them in the base directory.

Is this a bug? Should be in the target directory. Any workaround?

like image 567
DD. Avatar asked Jul 03 '12 15:07

DD.


People also ask

Why is dependency reduced POM created?

The dependency-reduced-pom. xml removes transitive dependencies which are already in your shaded jar. This prevents consumers from pulling them in twice.

What is the purpose of the maven shade plugin?

This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.

What is a shaded jar?

Shading is an extension to the uber JAR idea which is typically limited to use cases where. The JAR is a library to be used inside another application/library. The authors of the JAR want to be sure that the dependencies used by the JAR are in their control.

What is Maven classifier?

A Maven artifact classifier is an optional and arbitrary string that gets appended to the generated artifact's name just after its version number. It distinguishes the artifacts built from the same POM but differing in content.


2 Answers

You can avoid having it created by setting createDependencyReducedPom to false.

e.g.

<plugin>     <groupId>org.apache.maven.plugins</groupId>     <artifactId>maven-shade-plugin</artifactId>     <version>${maven-shade-plugin.version}</version>     <configuration>         <createDependencyReducedPom>false</createDependencyReducedPom>     </configuration>     ....     .... </plugin> 

See more detail from apache

enter image description here

like image 93
xverges Avatar answered Sep 21 '22 19:09

xverges


Based on bmargulies' answer and his comment on Xv.'s answer, I decided to configure the dependency-reduced POM to be output to target/, which is already ignored in my VCS.

To do that, I just added the dependencyReducedPomLocation element to the configuration element of the plugin, i.e.

<configuration>   <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>   (...) </configuration> 
like image 35
Zoltán Avatar answered Sep 22 '22 19:09

Zoltán