38

Is dependency-reduced-pom.xml created by Maven shade plugin automatically used in projects that depends on the uberjar (instead of the ordinary pom.xml)?

Asking this after reading a number of dependency-reduced-pom.xml related questions and haven't found the answer yet:

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

What is the purpose of dependency-reduced-pom.xml generated by the shade plugin?

What is `dependency-reduced-pom.xml` file which created when calling maven package command?

Rafid Aslam
  • 305
  • 3
  • 10
Johnny
  • 14,397
  • 15
  • 77
  • 118

1 Answers1

43

The dependency-reduced-pom.xml is generated at build time into ${basedir} of the project. This file is a temporary file that is only used for packaging into the shaded jar. Quoting the documentation of the createDependencyReducedPom attribute:

Flag whether to generate a simplified POM for the shaded artifact. If set to true, dependencies that have been included into the uber JAR will be removed from the <dependencies> section of the generated POM. The reduced POM will be named dependency-reduced-pom.xml and is stored into the same directory as the shaded artifact. Unless you also specify dependencyReducedPomLocation, the plugin will create a temporary file named dependency-reduced-pom.xml in the project basedir.

To make it clear, after the maven-shade-plugin has run:

  • your initial POM will be left unchanged;
  • a temporary file that you can completely ignore named dependency-reduced-pom.xml will have been generated inside the root folder (this is considered an open issue with this plugin);
  • the shaded artifact will contain your initial POM unchanged inside the META-INF directory and not the reduced POM (this is not really important but better mention it - there was an issue about this that was closed automatically: MSHADE-36);
  • the POM that will be deployed is the reduced POM;
  • the shaded artifact will be by default the main artifact of the project.
Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • Thanks, and I wondered where your answer disappeared :) Couple of points yet not clear: 1) If it's *temporary* file, why it's not deleted afterwords? 2) So, the answer is NO? Because of the MSHADE-36 issue you mentioned? 3) If MSHADE-36 got fixed and dependency reduced pom will to replace the packaged pom.xml, the answer will become YES? :) – Johnny Feb 02 '16 at 15:39
  • 1
    1) No idea. I guess it could be deleted, yes. I couldn't find an issue about this. 2) & 3) Actually the POM inside the META-INF folder is just informatory so it's not really important that it's not the reduced POM. Whay is important is that the deployed POM will be the reduced POM. So if you depend on the shaded artifact, you will depend on the reduced POM (that will effectively replace the "initial" POM). – Tunaki Feb 02 '16 at 15:52
  • @Tunaki The issue [MSHADE36](https://issues.apache.org/jira/browse/MSHADE-36) has been closed after 4 years of no interest..(No voting / no comment etc.) ..What do you think? Reopen it ? Offer a patch for it? – khmarbaise Feb 02 '16 at 17:21
  • 1
    @khmarbaise I'll see if I can reproduce the issue (because I made a first test and weirdly enough I didn't reproduce it -- maybe it was fixed in the mean time but wasn't traced in a bug report) – Tunaki Feb 02 '16 at 18:01