Skip to content

Instantly share code, notes, and snippets.

@matiasah
Created April 7, 2022 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matiasah/e8b20b72b358e20232f8cde41c501a44 to your computer and use it in GitHub Desktop.
Save matiasah/e8b20b72b358e20232f8cde41c501a44 to your computer and use it in GitHub Desktop.
Fix Lombok Coverage with JaCoCo

Maven Compiler Plugin

Add the maven-compiler-plugin before jacoco-maven-plugin

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <verbose>true</verbose>
    <fork>true</fork>
    <compilerVersion>${java.version}</compilerVersion>
    <source>${java.version}</source>
    <target>${java.version}</target>
    <meminitial>256</meminitial>
    <maxmem>1024</maxmem>
    <encoding>UTF-8</encoding>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-eclipse-compiler</artifactId>
    </dependency>
  </dependencies>
</plugin>

Add JaCoCo to your Maven project

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
    </execution>
    <execution>
      <id>report</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>report</goal>
      </goals>
    </execution>
    <execution>
      <id>post-unit-test</id>
      <phase>test</phase>
      <goals>
        <goal>report</goal>
      </goals>
    </execution>
  </executions>
</plugin>

lombok.config

Create the lombok.config file with the custom configuration.

# tells Lombok that this is the root directory and that it shouldn't search parent directories for more configuration files
config.stopBubbling = true

# tells Lombok to add @lombok.Generated annotation to all generated methods
lombok.addLombokGeneratedAnnotation = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment