Fix TestSourceJarMojo execute phase to generate-test-sources - #316
Open
elharo wants to merge 3 commits into
Open
Fix TestSourceJarMojo execute phase to generate-test-sources#316elharo wants to merge 3 commits into
elharo wants to merge 3 commits into
Conversation
Closes #304 The TestSourceJarMojo was forking to generate-sources instead of generate-test-sources. This caused test sources generated by other plugins in the generate-test-sources phase to not be available when the mojo runs, leading to an empty or incomplete test sources JAR. - Changed @execute(phase = generate-sources) to @execute(phase = generate-test-sources) - Added test to verify the correct phase is used
This integration test verifies that TestSourceJarMojo forks to generate-test-sources phase. It uses maven-antrun-plugin to generate a file in generate-test-sources phase and verifies it is included in the test sources JAR. Before the fix, the test-jar goal forks to generate-sources, so the antrun execution in generate-test-sources phase does not run and the generated file is not in the JAR. After the fix, the test-jar goal forks to generate-test-sources, so the antrun execution runs and the generated file is in the JAR.
This was referenced Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #304
The TestSourceJarMojo was forking to generate-sources instead of generate-test-sources. This caused test sources generated by other plugins in the generate-test-sources phase to not be available when the mojo runs, leading to an empty or incomplete test sources JAR.
Changes
Unit Test
The test testExecutePhase verifies that TestSourceJarMojo has @execute(phase = generate-test-sources). The test fails before the fix and passes after.
Integration Test
The integration test test-jar-generate-test-sources uses maven-antrun-plugin to generate a file in the generate-test-sources phase and verifies it is included in the test sources JAR. Before the fix, the test-jar goal forks to generate-sources, so the antrun execution does not run and the generated file is not in the JAR. After the fix, the test-jar goal forks to generate-test-sources, so the antrun execution runs and the generated file is in the JAR.
Note: The integration test requires Maven 4.0.0-beta-3 to run.