Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Generated factory for a Maven 4 API mojo requires a no-arg constructor

Open
#1,229 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@CaptainAni187 is already working on this.

Since Oct 6, 2026.

  • #1236 by @CaptainAni187 — open

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

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

bug
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/maven-plugin-tools

All issues in apache/maven-plugin-tools

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.