2

I took a project that uses maven-surefire-plugin (automated tests) to trigger JMH benchmarks and added module-info.java to it. Now, META-INF/BenchmarkList is no longer getting generated (in fact, the entire directory is missing) so I end up with the following error when launching the benchmarks:

ERROR: Unable to find the resource: /META-INF/BenchmarkList

I suspect that Java Modules is preventing the annotation processor from running properly, but I can't figure out how to fix it. Any ideas?

Gili
  • 81,444
  • 90
  • 364
  • 657
  • In general, it's really tough to figure out the error or its cause when there is not an [MCVE](https://stackoverflow.com/help/mcve) with the question though. Just sharing this since the question starts with maven-surefire and the answer ends it with maven-compiler instead. – Naman Dec 26 '18 at 07:53

1 Answers1

13

I figured it out through trial and error. It looks like a bug (or "feature") in maven-compiler-plugin 3.8.0. When module-info.java is present, the JMH annotation processor is no longer picked up automatically. Adding this configuration fixed the problem for me:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    [...]
        <annotationProcessorPaths>
            <path>
                <groupId>org.openjdk.jmh</groupId>
                <artifactId>jmh-generator-annprocess</artifactId>
                <version>${jmh.version}</version>
            </path>
        </annotationProcessorPaths>
    [...]
    </configuration>
</plugin>

UPDATE: I filed a bug report against maven-compiler-plugin.

Naman
  • 21,685
  • 24
  • 196
  • 332
Gili
  • 81,444
  • 90
  • 364
  • 657