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

28,322

Solution 1

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

Solution 2

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>

Solution 3

See https://issues.apache.org/jira/browse/MSHADE-121, and also https://issues.apache.org/jira/browse/MSHADE-124.

There is an option to move the d-r-p to elsewhere, but you may not like the consequences.

You are wrong about the -shaded jar, it always ends up in target/ unless you move it elsewhere.

Solution 4

You could use an old version of the plugin. Version 1.7 of the maven-shade-plugin writes to /target.

Since version 1.7.1, dependency-reduced pom.xml is written to basedir. See the issue MSHADE-124 for some reasons why it was done and what the consequences are. If you try setting dependencyReducedPomLocation, you will likely run into problems generating the site - open issue MSHADE-145.

Share:
28,322
DD.
Author by

DD.

Updated on July 08, 2022

Comments

  • DD.
    DD. almost 2 years

    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?

  • Artem
    Artem almost 12 years
    If you turn it off, then the thing you build will still have all the merged-in dependencies listed as dependencies.
  • Cristiano
    Cristiano over 10 years
    could you explain what should we do with this generated pom ?
  • Artem
    Artem over 10 years
    Nothing. Add it to your .gitignore file or set svn:ignore on it. Maven makes it so that it can include it in the shaded jar.
  • Gili
    Gili about 10 years
    What do you mean by You may not like the consequences? What are the negative consequences?
  • OhadR
    OhadR over 9 years
    they write (even in your answer you can see): "the plugin will create a temporary file named dependency-reduced-pom.xml in the project basedir"
  • Alexander Pogrebnyak
    Alexander Pogrebnyak over 7 years
    Bevare of this, from the plugin documentation "Where to put the dependency reduced pom. Note: setting a value for this parameter with a directory other than ${basedir} will change the value of ${basedir} for all executions that come after the shade execution. This is often not what you want. This is considered an open issue with this plugin."