Sharing components between build extension and plugin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Sharing components between build extension and plugin

Paul Benedict
Good day. I am seeking help for a Maven 3 (3.3.9) problem I am unable to
resolve. I've been hacking at it for about three weeks on-and-off and I
cannot find any solution. I've gone pretty much around the block both in
trial-and-error changes and web searches to no avail.

Here are the details in a simplified manner:

Project A
*) Common component library
*) A bunch of my own Plexus components
*) One such is @Component(role=Foo.class, instantiationStrategy="singleton")

Project B
*) Maven build extension
*) Dependent upon Project A artifact
*) One class of @Component(role = AbstractMavenLifecycleParticipant.class)
*) Takes the injected Foo component and stuffs it into a plugin context

Project C
*) Maven build plugin
*) Dependent upon Project A artifact
*) Retrieves Foo component instance from its plugin context

Project D
*) Application
*) POM specifies build <extension> of Project B's artifact
*) POM specifies build <plugin>

When I build Project D, I cannot ever get the extension (Project B) and the
plugin (Project C) to ever see the same instance of Foo. As I said, I have
tried a myriad of configurations without success. The build dies with a
CastClassException because the extension and plugin clearly have a
different Class<Foo> instance.

So my question is...

What is the cookbook formula where a build extension and a build plugin,
specified in the same POM, are able to share one and only one instance of
Foo component?

Cheers and God bless,