Skip to content

[MCOMPILER-607] - Build fails when annotation processor list is empty (but present) - #1077

Open
wilx wants to merge 2 commits into
apache:maven-compiler-plugin-3.xfrom
wilx:fix-892-empty-annotation-processors
Open

[MCOMPILER-607] - Build fails when annotation processor list is empty (but present)#1077
wilx wants to merge 2 commits into
apache:maven-compiler-plugin-3.xfrom
wilx:fix-892-empty-annotation-processors

Conversation

@wilx

@wilx wilx commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #892. [MCOMPILER-607] Build fails when annotation processor list is empty (but present)

When Maven maps an explicitly empty <annotationProcessors> configuration block, the resulting array contains a blank value rather than being empty or null. The 3.x compiler plugin passes that array to Plexus Compiler, which then invokes javac with -processor "". Compilation fails because the empty processor name cannot be resolved.

This change treats an annotation processor array containing only blank values as unspecified before passing it to Plexus Compiler. Normal non-blank processor lists retain their existing behavior.

A regression test uses an actually empty XML <annotationProcessors> block and verifies that compilation succeeds. This covers the Maven configuration-mapping behavior that caused the bug.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MCOMPILER-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MCOMPILER-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@wilx
wilx marked this pull request as ready for review July 12, 2026 14:54
@elharo
elharo requested a review from Copilot July 28, 2026 11:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes a Maven configuration edge case where an explicitly empty <annotationProcessors> block is mapped to an array containing blank strings, which then causes javac to be invoked with an invalid -processor "" argument.

Changes:

  • Normalize annotationProcessors so an array containing only blank values is treated as “unspecified” (null) before passing to Plexus Compiler.
  • Add a regression unit test project/config that uses an actually empty <annotationProcessors> XML block.
  • Add a unit test asserting compilation succeeds with that configuration.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java Treats “all-blank” annotation processor arrays as unspecified to avoid passing -processor "" to javac.
src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTest.java Adds a unit test that runs compilation with an empty <annotationProcessors> block and asserts output class exists.
src/test/resources/unit/compiler-empty-annotation-processors-test/plugin-config.xml New test config reproducing Maven’s empty block mapping behavior.
src/test/resources/unit/compiler-empty-annotation-processors-test/src/main/java/TestCompile.java Minimal compilation unit for the new regression test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +861 to +865
String[] processors = annotationProcessors;
if (processors != null && Arrays.stream(processors).allMatch(StringUtils::isBlank)) {
processors = null;
}
compilerConfiguration.setAnnotationProcessors(processors);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants