Generated factory for a Maven 4 API mojo requires a no-arg constructor
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- build-system, tooling
Research direction
Start in DescriptorGeneratorMojo.java around line 530, following the descriptor goal's generated Factory constructor. Use the supplied constructor-injected ReproMojo to reproduce the runtime failure with Maven 4. Done means the generated factory handles the mojo's @Inject constructor, or descriptor rejects a mojo without a no-arg constructor instead of producing a failing plugin.
Written by the indexing model from the issue text.
Description
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). 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:
@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.
- Dominant language
- Java
- Stars
- 63
- Forks
- 76
- Avg merge
- 20h 52m
- Merged PRs (30d)
- 21
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/maven-plugin-tools
-
`@Execute` with a custom phase or `"none"` fails descriptor extractionPossibly taken @CaptainAni187 claimed this 12 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/maven-plugin-tools#1232 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
apache/maven-plugin-tools#1240 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
apache/maven-plugin-tools#1233 · 5 comments ·
Maintainers usually reply within 1 day
-
`descriptor` fails on `onlineRequired`, `dependencyCollection` and `dependencyResolutionPathScopes` in the Maven 4 API `@Mojo`Possibly taken @efegokdemir claimed this 10 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
apache/maven-plugin-tools#1231 · 1 comment ·
Maintainers usually reply within 1 day
-
`@Resolution` fields stay null: `plugin.xml` gets no `<resolutions>`Possibly taken @goutamadwant claimed this 15 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 72/100
apache/maven-plugin-tools#1230 · 1 comment ·
Maintainers usually reply within 1 day
All issues in apache/maven-plugin-tools
Similar issues
-
NullPointerException when a `DeserializationProblemHandler` returns `null` for `byte[]` (single value unwrapped) and `char[]` elementsPossibly taken @Marti2203 claimed this today. Open
Difficulty 2/5 Half a day Newbie friendliness 88/100
FasterXML/jackson-databind#6300 ·
Maintainers usually reply within 1 day
-
content good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
cpinitiative/usaco-guide#6699 ·
Maintainers usually reply within 1 day
-
BC remittance upload: a claim MSP refused (S03) is saved with a blank status instead of refused (F)Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
carlos-emr/carlos#4933 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/rocketmq-dashboard#6925 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Vakore/ZappierGames#147 ·