Fix NullPointerException in Antlr4MojoTest by downgrading Maven API to 3.6.3#4947
Open
Nokhrin wants to merge 2 commits into
Open
Fix NullPointerException in Antlr4MojoTest by downgrading Maven API to 3.6.3#4947Nokhrin wants to merge 2 commits into
Nokhrin wants to merge 2 commits into
Conversation
- Fix typo in class name: 'Intrepreter' -> 'Interpreter' - Replace abstract 'input-filename(s)' with 'source-code-file(s)' to clarify that the tool expects plain text source code files, not compiled binaries. - Update the stdin fallback message to use the new terminology and replace the ambiguous word 'rig' with 'the tool'. Signed-off-by: Aleksandr Nokhrin <a.v.nokhrin@yandex.ru>
Signed-off-by: Aleksandr Nokhrin <a.v.nokhrin@yandex.ru>
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.
Problem
Running
mvn test(ormvn packagewithout-DskipTests) in theantlr4-maven-pluginmodule fails withNullPointerExceptionin all4 tests of
Antlr4MojoTest:Root cause: The module depends on
takari-plugin-testing:3.0.0,which was last released in 2018 and relies on internal Maven APIs that
were changed in Maven 3.8+. Specifically,
MojoExecution.getPlugin()now returns
nullin the test harness, triggering the NPE inDefaultMojoExecutionConfigurator.Solution
Downgrade the
mavenVersionproperty inantlr4-maven-plugin/pom.xmlfrom3.8.5to3.6.3. This is thelast Maven version that is compatible with
takari-plugin-testing:3.0.0.The plugin itself continues to work with modern Maven installations
— this change only affects the version of Maven API used by the test
harness.
Before
After
Verification
Before the fix
Running
mvn test -pl antlr4-maven-pluginresulted in:After the fix
After downgrading
mavenVersionfrom3.8.5to3.6.3:$ mvn test -pl antlr4-maven-pluginResult:
All 4 tests that previously failed with
NullPointerExceptionnow pass successfully:importTokensimportsCustomLayoutimportsStandardLayoutprocessWhenDependencyRemovedNote
A more thorough fix would be to migrate from the abandoned
takari-plugin-testing:3.0.0to the official Apachemaven-plugin-testing-harness:3.3.0, which is actively maintainedand compatible with modern Maven versions. However, such a migration
would require significant refactoring of the test suite:
TestMavenRuntimeandTestResources(JUnit 4@Rule-based API)would need to be replaced with
LookupMojoandPlexusTestCasefrom the Apache harness.
src/test/projects/might requireadjustments to their POM structures.
This minimal fix restores the CI pipeline without introducing the
risk of breaking the test suite. The migration to
maven-plugin-testing-harnessis recommended as a follow-up taskbut is outside the scope of this PR.