Well, maven-shade-plugin does "attach" the dependency-reduced POM: https://github.com/apache/maven-shade-plugin/blob/768092f38b0b1650217642cf10b7b0c381cbf707/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java#L1191 At least when you install or deployed, that POM gets installed/deployed rather than the original one.
Le dim. 25 avr. 2021 à 04:09, Alexander Kriegisch <[email protected]> a écrit : > I am sorry if I am asking a question the answer to which might be obious > to others, but for a long time I have wondered why I do not find any > examples for the following use case which IMO is probably quite common: > > ** I build an uber JAR containing some module dependencies, possibly > also transitive ones. This could be done using Maven Shade or Maven > Assembly, maybe even something with nested JARs like One-JAR. > ** The built uber JAR replaces the module's original artifact when > installed and/or deployed. > ** By default, the original POM gets attached to the build. This is > undesirable, because the uber JAR no longer depends on those > dependencies. They are only needed in the POM during the build as > such in order to be able to include them in the uber JAR at all. > > My question: How do I automatically create and attach a > dependency-reduced POM to the build, replacing the original POM? > Ideally, I would have options to also filter out other POM elements such > as repositories, but that is optional and not the main scope of this > question. > > Presently, I use Flatten Maven Plugin for this purpose. For certain > reasons, I am not very happy with it because it requires extra work, it > mutilates my POMs with regard to formatting and removing things I do not > wish to be removed, but it works. > > I also know that Maven Shade automatically creates a dependency-reduced > POM if not told otherwise. But that POM is not attached to the build. > Maybe I could do so using Build Helper, but both Flatten Maven and Build > Helper seem like crutches, and I cannot help but wonder which built-in > Maven functionality escaped my attention so far. Is there a canonical > way to do that, such as resource filtering? Can I even apply that to > POMs? I feel like I might be doing something phenomenally stupid, > possibly missing a more straightforward way of solving this problem. > > -- > Alexander Kriegisch > https://scrum-master.de > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
