I think the idea of the flatten-maven-plugin is a Good Idea. It removes any
inheritance in the POM structure before publishing to a repository. It is a
"weak" implementation of the consumer POM that Maven is working towards. It
doesn't change your artifacts, it just flattens the POM so it isn't
dependending on any parent when published. I use it in a lot of projects
which only publish some of the modules and I don't like the parent to be
published. When you publish your parent, you have to take
responsibility for it. I only publish the modules I would like to share,
without inheritance. It also makes it easier with dependency management,
the reasoning about which import takes preference with an inherited parent
import is really hard to understand.

Take a look at it, and maybe it will solve your problem.

Nick Stolwijk

~~~ Try to leave this world a little better than you found it and, when
your turn comes to die, you can die happy in feeling that at any rate you
have not wasted your time but have done your best ~~~

Lord Baden-Powell


On Mon, 31 Jul 2023 at 00:45, Garret Wilson <gar...@globalmentor.com> wrote:

> On 7/30/2023 7:34 PM, Nick Stolwijk wrote:
> > I am missing the purpose of publishing the parent pom. Is it because
> other
> > projects can inherit of it,
>
> Yes.
>
> > or is it because your own projects (that you
> > want to be published) are inherited from it?
>
> Yes.
>
> > In the second case, you can use the maven-flatten-plugin to have the
> > published projects not be dependent on your parent project. In that case
> > you can use the parent projects <pluginManagement> to setup the
> > configuration and activate it in the child modules in the build section.
> If
> > you enable the maven-flatten-plugin in the parent project for each child
> > project there is no project inheritance anymore in the published
> artifacts,
> > so there is no need to publish your parent pom.
>
> I confess I don't know much about the Maven Flatten Plugin, but it
> sounds suspiciously like the Maven Shade Plugin, which Seemed Like A
> Good Idea At The Time To Muck With Everything, but from much personal
> experience the details bring nothing but pain and suffering.
>
> So if I flatten everything, how do I publish a BOM of my multimodule
> aggregate subprojects without bringing in project-specific dependencies
> that shouldn't go in the BOM?
>
> I don't want to dismiss suggestions too quickly if I don't fully
> understand them, but sincerely, just the idea sound like it would bring
> lots of tears for years and years.
>
> Garret
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>

Reply via email to