[
https://issues.apache.org/jira/browse/MNG-8185?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17867679#comment-17867679
]
Tamas Cservenak commented on MNG-8185:
--------------------------------------
In general, calling Mojo from a Mojo is a no-no. That would create nested Maven
classloaders and so on.
In ideal world, a maven plugin is "thin", should contain Mojos only, and plugin
should use reusable lib/component dependency (that in turn can be reused).
Such idea was drafted in gh/maveniverse/toolbox where all the logic is in
"shared" bit that is reusable.
> Embedder's MavenCli cannot be executed from another plugin Mojo.
> -----------------------------------------------------------------
>
> Key: MNG-8185
> URL: https://issues.apache.org/jira/browse/MNG-8185
> Project: Maven
> Issue Type: Bug
> Components: Embedding
> Affects Versions: 3.9.8
> Reporter: Ozgun OZ
> Priority: Major
>
>
> I am trying to run the maven-embedder from a plugin's Mojo that I develop.
> I am using the mavenCli like below,
>
> {code:java}
> MavenCli cli = new MavenCli();
> cli.doMain(new String[] {"clean","compile"},
> project.getBasedir().getAbsolutePath(), System.out, System.err); {code}
>
> Here are the dependencies in my pom.xml
>
>
> {code:java}
> <dependency>
> <groupId>org.apache.maven</groupId>
> <artifactId>maven-embedder</artifactId>
> <version>3.9.8</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.maven</groupId>
> <artifactId>maven-compat</artifactId>
> <version>3.9.8</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org.eclipse.sisu</groupId>
> <artifactId>org.eclipse.sisu.plexus</artifactId>
> <version>0.3.5</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org.eclipse.sisu</groupId>
> <artifactId>org.eclipse.sisu.inject</artifactId>
> <version>0.3.5</version>
> <scope>provided</scope>
> </dependency> {code}
> The full source code of the plugin can be found here:
> [https://github.com/HomeOfTheWizard/spring-bridge-maven-plugin/tree/feature/embedder-for-compilation]
>
> When using this plugin in another maven plugin project,
> I have the following error.
> {code:java}
> [INFO] [ERROR] Error executing Maven.
> [INFO] [ERROR] Unable to create injector, see the following errors:
> [INFO]
> [INFO] 1) [Guice/ScopeNotFound]: No scope is bound to SessionScoped.
> [INFO]
> [INFO] Used at:
> [INFO] 1 : ReactorReader.class(ReactorReader.java:63)
> [INFO] at ClassRealm[plexus.core, parent: null]
> [INFO] \_ installed by: WireModule -> PlexusBindingModule
> [INFO]
> [INFO] Learn more:
> [INFO] https://github.com/google/guice/wiki/SCOPE_NOT_FOUND
> [INFO]
> [INFO] 1 error
> [INFO]
> [INFO] ======================
> [INFO] Full classname legend:
> [INFO] ======================
> [INFO] PlexusBindingModule: "org.eclipse.sisu.plexus.PlexusBindingModule"
> [INFO] ReactorReader: "org.apache.maven.ReactorReader"
> [INFO] SessionScoped: "org.apache.maven.SessionScoped"
> [INFO] WireModule: "org.eclipse.sisu.wire.WireModule"
> [INFO] ========================
> [INFO] End of classname legend:
> [INFO] ======================== {code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)