среда, 4 сентября 2019 г.

sonar + lombok + maven + jacoco

1) To avoid Sonar warnings of "unused private fields" or other warnings when you use Lombok annotatios like @Data or @Getter(lazy = true) you need just add lombok library to you building directory using maven-dependency plugin
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <includeArtifactIds>lombok</includeArtifactIds>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

And after that you can add library in your sonar.properties

sonar.java.libraries=target/dependency/*.jar

2) Excluding lombok annotation from test coverage.

To avoid this you need to add lombok.config file in your app root folder with this parameters

config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true

config.stopBubbling = true is telling Lombok that this is the root and that it shouldn’t search parent directories for more configuration files (you can have more than one Lombok config files in different directories/packages).
lombok.addLombokGeneratedAnnotation = true is telling Lombok to add @lombok.Generated annotation to all generated methods.

Комментариев нет:

Отправить комментарий