Skip to content
Sam Meng edited this page Jun 11, 2020 · 3 revisions

Lombok Support

It is possible to integrate Enunciate with Project Lombok. This support includes allowing Enunciate to detect JavaDocs on fields that are Lombok annotated.

Enunciate 2.7+

As of Enunciate 2.7, Enunciate provides a lombok-support module that will natively handle Lombok annotations. It is an optional module, and will therefore need to be explicitly included in the Enunciate classpath. Maven users do it like this:

<plugin>
  <groupId>com.webcohesion.enunciate</groupId>
  <artifactId>enunciate-maven-plugin</artifactId>
  <version>${enunciate.version}</version>

  <configuration>
    ...
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>assemble</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>com.webcohesion.enunciate</groupId>
      <artifactId>enunciate-lombok</artifactId>
      <version>${enunciate.version}</version>
    </dependency>
  </dependencies>
</plugin>

Enunciate < 2.7

This is done in two steps:

  1. Configure Lombok to Generate the Sources
  2. Configure Enunciate to Use the Generated Sources

You may also find the thread at #182 useful.

Maven Example

Configure Lombok to Generate the Sources

      <plugin>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok-maven-plugin</artifactId>
        <version>${lombok.version}</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>delombok</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <encoding>utf-8</encoding>
          <addOutputDirectory>false</addOutputDirectory>
          <sourceDirectory>src/main/java</sourceDirectory>
        </configuration>
      </plugin>

The Lombok plugin will put the generated sources in ${project.build.directory}/generated-sources/delombok.

Set the Enunciate Compiler Directory

      <plugin>
        <groupId>com.webcohesion.enunciate</groupId>
        <artifactId>enunciate-maven-plugin</artifactId>
        <version>${enunciate.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>assemble</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/delombok</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
Clone this wiki locally