TestSourceJarMojo forks to generate-sources instead of generate-test-sources

Open
#304 3 comments 0 reactions 1 assignee View on GitHub

@elharo is already working on this.

Since Aug 5, 2026.

Assessment

This issue has not been assessed yet.

Description

bug priority:major

TestSourceJarMojo.java:28 has @Execute(phase = "generate-sources"):

@Mojo(name = "test-jar", defaultPhase = "package")
@Execute(phase = "generate-sources")
public class TestSourceJarMojo extends TestSourceJarNoForkMojo {

This is a test-jar goal but forks only to generate-sources, not generate-test-sources. If test sources are generated by another plugin in the generate-test-sources phase, they will not be available when the mojo runs, leading to an empty or incomplete test sources JAR.

Compare with TestSourceGeneratedJarMojo.java:28 which correctly uses generate-test-sources:

@Mojo(name = "generated-test-jar", defaultPhase = "package")
@Execute(phase = "generate-test-sources")
public class TestSourceGeneratedJarMojo extends TestSourceJarNoForkMojo {

Fix: Change the phase to generate-test-sources.

Dominant language
Java
Stars
37
Forks
38
Avg merge
12h 11m
Merged PRs (30d)
6

Contributor guide

No contributing guide indexed for this repository

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-source-plugin

All issues in apache/maven-source-plugin

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.