Skip to content

Conversation

@desruisseaux
Copy link
Contributor

In Maven 4, the recommended way to add a JAR on the annotation processor classpath is like below:

<project>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven.plugins.compiler.it</groupId>
      <artifactId>annotation-processor</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>processor</type>
    </dependency>
  </dependencies>
</project>

However, Maven Compiler Plugin 4.0.0-beta-3 does not automatically detects the processor if it is declared only as above. This commit fixes that issue and adds an integration test, together with opportunistic cleaning in other integration tests.

In the main time, as a workaround, adding the following configuration seems to work, where org.foo.MyAnnotationProcessor is the value declared in the META-INF/services/javax.annotation.processing.Processor file. Note that only the processor class is declared, not the artifact coordinates:

<project>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <annotationProcessors>
            <annotationProcessor>org.foo.MyAnnotationProcessor</annotationProcessor>
          </annotationProcessors>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

@desruisseaux desruisseaux requested a review from bmarwell October 26, 2025 18:19
@desruisseaux desruisseaux self-assigned this Oct 27, 2025
@desruisseaux desruisseaux added the bug Something isn't working label Oct 27, 2025
@desruisseaux desruisseaux added this to the 4.0.0-beta-4 milestone Oct 27, 2025
Comment on lines +70 to +74
## Removed JUnit tests
Removed the following directories and associated test methods:

* `compiler-one-output-file-test2` because it was redundant with `compiler-one-output-file-test`.

The only difference was the addition of include/exclude filters, but that difference had
no effect because the compiler mock used in this test was ignoring all sources anyway.
This test has been replaced by `compiler-modular-project`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think no one will care in the future about this. This is appropriate for this PR / issue to mention once, but for future use it is probably uninteresting.

Copy link
Contributor Author

@desruisseaux desruisseaux Oct 27, 2025

Choose a reason for hiding this comment

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

The purpose of this file is to document the differences between the 3.x and 4.0 branches. The compiler-one-output-file-test2 directory is still present in the 3.x branch. Because some tests have been added in the 3.x branch without being ported yet to the 4.0 branch (e.g., MCOMPILER-538), in the future we may want to compare the two branches for checking which tests present in one branch are missing in the other branch. This note is for remembering to not port that directory.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I thought that should be obvious when browsing through the history, as the history would now have a reference to an issue. But now that you mention it, your commits do not have an issue linked, it seems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I'm lazily mixing two works in this same pull request. The work that really solves the issue described in this issue is the "Fix: annotation processor not always detected when specified with processor" commit. But since this commit adds a new integration test, this pull request opportunistically does some cleanup in those tests first. Those cleanups are in separated commits, with the intend to not squash them. The README.md file is added as part of this cleanup, but it describes changes that were actually done long ago.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I'm lazily mixing two works in this same pull request.

then why all those renames :D :D :D 💋

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is because some integration tests were using the install goal. I replaced some install by verify in this commit but a few remain if I remember right. The use of install goal in integration tests pollutes the ~/.m2/repository/ directory. By using the org.apache.maven.plugins.compiler.it groupId for all tests, we ensure that if some install goals are used again for whatever reason, at least we have a single place to cleanup in the .m2/repository directory.

Comment on lines +70 to +74
## Removed JUnit tests
Removed the following directories and associated test methods:

* `compiler-one-output-file-test2` because it was redundant with `compiler-one-output-file-test`.

The only difference was the addition of include/exclude filters, but that difference had
no effect because the compiler mock used in this test was ignoring all sources anyway.
This test has been replaced by `compiler-modular-project`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I'm lazily mixing two works in this same pull request.

then why all those renames :D :D :D 💋

…ype>processor</type>`.

Replace some relatively verbose "is null or empty" checks by `isAbsent(…)` methods.
…undError`.

It may happen when an annotation processor is present but has a dependency which is missing.
@desruisseaux desruisseaux merged commit c3fc26a into apache:master Nov 2, 2025
33 of 40 checks passed
@desruisseaux desruisseaux deleted the fix/processor-type branch November 2, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants