maven-enunciate-plugin java 7

It is possible to get the maven-enuniciate-plugin to work with Java 7. You might see an error like this:

[ERROR] Failed to execute goal org.codehaus.enunciate:maven-enunciate-plugin:1.24:docs (default) on project Pluto: Execution default of goal org.codehaus.enunciate:maven-enunciate-plugin:1.24:docs failed: A required class was missing while executing org.codehaus.enunciate:maven-enunciate-plugin:1.24:docs: com/sun/mirror/apt/AnnotationProcessorFactory

Looks like the tools.jar is not available in Java 7 by default. You need to add it as a dependency of the enunciate plugin. If you are using some other (non sun/oracle) JDK then the solution will be different, you may need to use maven profiles for each JDK you want to use.

You can add tools.jar as a dependency like this:

<plugin>
   <groupId>org.codehaus.enunciate</groupId>
   <artifactId>maven-enunciate-plugin</artifactId>
   <configuration>
      <configFile>src/main/doc/enunciate.xml</configFile>
   </configuration>
   <executions>
      <execution>
         <goals>
            <goal>docs</goal>
         </goals>
         <configuration>
            ...
         </configuration>
      </execution>
   </executions>
   <dependencies>
      <dependency>
         <groupId>com.sun</groupId>
         <artifactId>tools</artifactId>
         <version>${java.version}</version>
         <scope>system</scope>
         <systemPath>${java.home}/../lib/tools.jar</systemPath>
      </dependency>
   </dependencies>
</plugin>

You will now get a warning, which hopefully enunciate will fix sometime before java 8!

warning: The apt tool and its associated API are planned to be
removed in the next major JDK release.  These features have been
superseded by javac and the standardized annotation processing API,
javax.annotation.processing and javax.lang.model.  Users are
recommended to migrate to the annotation processing features of
javac; see the javac man page for more information.

Leave a Reply

Your email address will not be published. Required fields are marked *