slachiewicz opened a new issue, #1229: URL: https://github.com/apache/maven-plugin-tools/issues/1229
### Affected version 4.0.0-beta-3; the code is unchanged on master ### Bug description For each Maven 4 API mojo, the `descriptor` goal generates a `<Mojo>Factory` subclass whose only constructor calls the mojo's no-arg constructor ([DescriptorGeneratorMojo.java:530](https://github.com/apache/maven-plugin-tools/blob/master/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGeneratorMojo.java#L530)). A mojo that uses constructor injection and has no no-arg constructor builds cleanly, then fails when the goal runs: ``` Caused by: org.apache.maven.di.impl.DIException: Failed to call constructor public repro.ReproMojoFactory() to provide requested key @Named("repro:ctor-maven-plugin:1.0-SNAPSHOT:run") ReproMojoFactory Caused by: java.lang.NoSuchMethodError: repro.ReproMojo: method 'void <init>()' not found ``` Reproducer, built with maven-plugin-plugin 4.0.0-beta-3 and run with Maven 4.0.0-rc-7: ```java @Mojo(name = "run") public class ReproMojo implements org.apache.maven.api.plugin.Mojo { private final Log log; @Inject public ReproMojo(Log log) { this.log = log; } public void execute() { log.info("constructor-injected mojo ran"); } } ``` Expected: the factory mirrors the mojo's `@Inject` constructor and passes its parameters to `super(...)`. Failing that, `descriptor` should reject a mojo without a no-arg constructor instead of producing a plugin that fails at run time. The Maven 4 API ports in apache/maven#13302 had to switch mojos from constructor to field injection because of this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
