Register a Mojo from an extension

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Register a Mojo from an extension

François Guillot
Hi,

I have a custom maven extension, that contains an EventSpy as its entry
point.
I would also like to have several Mojo implementations in my extension jar,
and make them available for consumption by users, as long as they apply the
extension.

I have a simple HelloWorldMojo, and a corresponding
META-INF/maven/plugin.xml in my extension jar.
When calling my mojo, after applying my extension, I get

[WARNING] Error injecting: HelloWorldMojo
java.lang.TypeNotPresentException: Type HelloWorldMojo not present
    at org.eclipse.sisu.space.URLClassSpace.loadClass
(URLClassSpace.java:143)
    at org.eclipse.sisu.space.NamedClass.load (NamedClass.java:46)
    at org.eclipse.sisu.space.AbstractDeferredClass.get
(AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision
(ProviderInternalFactory.java:85)
    at
com.google.inject.internal.InternalFactoryToInitializableAdapter.provision
(InternalFactoryToInitializableAdapter.java:57)
    at com.google.inject.internal.ProviderInternalFactory$1.call
(ProviderInternalFactory.java:66)
    at
com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision
(ProvisionListenerStackCallback.java:112)
    at
com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision
(ProvisionListenerStackCallback.java:127)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision
(ProvisionListenerStackCallback.java:66)
    at com.google.inject.internal.ProviderInternalFactory.circularGet
(ProviderInternalFactory.java:61)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get
(InternalFactoryToInitializableAdapter.java:47)
    at com.google.inject.internal.InjectorImpl$1.get
(InjectorImpl.java:1050)
    at org.eclipse.sisu.inject.Guice4$1.get (Guice4.java:162)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue
(LazyBeanEntry.java:81)
    at org.eclipse.sisu.plexus.LazyPlexusBean.getValue
(LazyPlexusBean.java:51)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup
(DefaultPlexusContainer.java:263)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup
(DefaultPlexusContainer.java:255)
    at
org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo
(DefaultMavenPluginManager.java:520)

I suspect that my Mojo class is not available in the 'main' classpath, only
on the extension classpath. Is that the case ?
How can I register my mojo fro my extension then ?
Reply | Threaded
Open this post in threaded view
|

Re: Register a Mojo from an extension

François Guillot
Found the problem
I needed to export my package from my extension.xml

On 2019/09/11 11:00:41, François Guillot <[hidden email]> wrote:
> Hi,>
>
> I have a custom maven extension, that contains an EventSpy as its entry>
> point.>
> I would also like to have several Mojo implementations in my extension
jar,>
> and make them available for consumption by users, as long as they apply
the>

> extension.>
>
> I have a simple HelloWorldMojo, and a corresponding>
> META-INF/maven/plugin.xml in my extension jar.>
> When calling my mojo, after applying my extension, I get>
>
> [WARNING] Error injecting: HelloWorldMojo>
> java.lang.TypeNotPresentException: Type HelloWorldMojo not present>
>     at org.eclipse.sisu.space.URLClassSpace.loadClass>
> (URLClassSpace.java:143)>
>     at org.eclipse.sisu.space.NamedClass.load (NamedClass.java:46)>
>     at org.eclipse.sisu.space.AbstractDeferredClass.get>
> (AbstractDeferredClass.java:48)>
>     at com.google.inject.internal.ProviderInternalFactory.provision>
> (ProviderInternalFactory.java:85)>
>     at>
>
com.google.inject.internal.InternalFactoryToInitializableAdapter.provision>
> (InternalFactoryToInitializableAdapter.java:57)>
>     at com.google.inject.internal.ProviderInternalFactory$1.call>
> (ProviderInternalFactory.java:66)>
>     at>
>
com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision>

> (ProvisionListenerStackCallback.java:112)>
>     at>
>
com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision>

> (ProvisionListenerStackCallback.java:127)>
>     at
com.google.inject.internal.ProvisionListenerStackCallback.provision>
> (ProvisionListenerStackCallback.java:66)>
>     at com.google.inject.internal.ProviderInternalFactory.circularGet>
> (ProviderInternalFactory.java:61)>
>     at
com.google.inject.internal.InternalFactoryToInitializableAdapter.get>

> (InternalFactoryToInitializableAdapter.java:47)>
>     at com.google.inject.internal.InjectorImpl$1.get>
> (InjectorImpl.java:1050)>
>     at org.eclipse.sisu.inject.Guice4$1.get (Guice4.java:162)>
>     at org.eclipse.sisu.inject.LazyBeanEntry.getValue>
> (LazyBeanEntry.java:81)>
>     at org.eclipse.sisu.plexus.LazyPlexusBean.getValue>
> (LazyPlexusBean.java:51)>
>     at org.codehaus.plexus.DefaultPlexusContainer.lookup>
> (DefaultPlexusContainer.java:263)>
>     at org.codehaus.plexus.DefaultPlexusContainer.lookup>
> (DefaultPlexusContainer.java:255)>
>     at>
>
org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo>

> (DefaultMavenPluginManager.java:520)>
>
> I suspect that my Mojo class is not available in the 'main' classpath,
only>
> on the extension classpath. Is that the case ?>
> How can I register my mojo fro my extension then ?>
>