3

I'm following maven tutorial from springsource here, and after 1) adding joda-time dependency , and 2) calling mvn package commmand, we get the below file dependency-reduced-pom.xml.

My question is, what is the purpose of creating this file besides pom.xml file?

enter image description here

Nam G VU
  • 33,193
  • 69
  • 233
  • 372
  • 1
    I guess you are using the maven-shade-plugin? http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html#createDependencyReducedPom – coderplus Oct 22 '14 at 06:45
  • Yeah, it is. The tutorial use it. – Nam G VU Oct 22 '14 at 07:53
  • 1
    possible duplicate of [Maven shade plugin adding dependency-reduced-pom.xml to base directory](http://stackoverflow.com/questions/11314182/maven-shade-plugin-adding-dependency-reduced-pom-xml-to-base-directory) – Joe Oct 22 '14 at 11:52
  • Possible duplicate of [What is the purpose of dependency-reduced-pom.xml generated by the shade plugin?](https://stackoverflow.com/questions/22904573/what-is-the-purpose-of-dependency-reduced-pom-xml-generated-by-the-shade-plugin) – sleske Apr 16 '18 at 11:13

2 Answers2

7

If you set to true the flag createDependencyReducedPom (by default is true), the 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.

Extracted from here http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html#createDependencyReducedPom

enter image description here

Nam G VU
  • 33,193
  • 69
  • 233
  • 372
Iker Aguayo
  • 3,980
  • 4
  • 37
  • 49
  • 1
    So that means when the dependencies are in the .jar already, we don't have to mention them in the to-be application `pom.xml` right i.e. `dependency-reduced-pom.xml` will be used as pom.xml? – Nam G VU Oct 22 '14 at 07:55
  • I think that, that is a another question and maybe should be in another thread. But as I understand, I would work in the original pom.xml and I would avoid the dependency reduced pom (createDependencyReducedPom to false) – Iker Aguayo Oct 22 '14 at 13:34
  • How do you set the `createDependencyReducedPom` to false? – Bram Apr 11 '23 at 21:03
2

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

Well, if you have a module A with X dependencies, and shade some of them in a specific JAR (A-shaded.jar), then you won't need those shaded dependencies if you want to depend on A-shaded.jar instead of A.jar. So the plugin creates a pom.xml containing only the Y non-shaded dependencies.

Community
  • 1
  • 1
OhadR
  • 8,276
  • 3
  • 47
  • 53