When building a Maven site, why does my annotation processor run twice and break the build?

StackOverflow https://stackoverflow.com/questions/14746971

  •  07-03-2022
  •  | 
  •  

Question

I have a build that uses the annotation processor plugin to generate JPA criteria classes with the Hibernate JPA 2 Metamodel Generator.

This works well when doing a normal mvn clean package, but when I build the site, it fails:

[INFO] --- maven-processor-plugin:2.1.0:process (generate-jpa-metamodel) @ phtool-api ---
[INFO] Source directory: C:\jp\esv-projects\phtool\phtool-api\target\generated-sources\jpa added
[INFO] javac option: -cp
[INFO] javac option: ...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: C:\jp\esv-projects\phtool\phtool-api\target\classes
[INFO] javac option: -s
[INFO] javac option: C:\jp\esv-projects\phtool\phtool-api\target\generated-sources\jpa
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.2.0.Final
[INFO] diagnostic C:\jp\projects\phtool\phtool-api\target\generated-sources\jpa\phtool\impl\resource\ImageImpl_.java:10: error: duplicate c
lass: phtool.impl.resource.ImageImpl_

I noticed that the plugin runs twice during the site generation, but I don't know why. Perhaps it's a known Javadoc plugin bug?

Was it helpful?

Solution

The problem is solved now, through changes in the parent POM. I can't exactly tell what change solved the problem, but here are the relevant versions within my POM:

      <groupId>org.bsc.maven</groupId>
      <artifactId>maven-processor-plugin</artifactId>
      <version>2.2.4</version>

      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.1</version>

      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-site-plugin</artifactId>
      <version>3.3</version>

      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>2.9</version>

Note that the version of the Javadoc plugin hasn't changed!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top