Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#1,229 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@CaptainAni187 ci sta già lavorando.

Dal 6/10/2026.

  • #1236 di @CaptainAni187 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
63
Fork
76
Merge medio
1g 8h
PR unite (30g)
19

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/maven-plugin-tools

Tutte le issue di apache/maven-plugin-tools

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.