'Sonar Doesn't pick lombok Annotations ( Remove unused private field)

I am using sonar version 8.9.6. I know this issue has been asked around a lot of times and i have tried a lot of those and none of the solutions has worked for me.

following are some of the things that i have tried.

1)

<sonar.exclusions>
        // my domain package here
        </sonar.exclusions>
  1. added the following plugin

               <plugin>
       <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                  <includeArtifactIds>lombok</includeArtifactIds>
                </configuration>
              </execution>
            </executions>
          </plugin>
    

and then added the following property

<sonar.java.libraries>target/dependency/*.jar</sonar.java.libraries>
  1. Added lombok.config and added the following properties

    config.stopBubbling = true lombok.addLombokGeneratedAnnotation = true

None of these have worked for me and especially sonar exclusions doesn't work at all. Any help would be appreciated and Thanks in advance.



Solution 1:[1]

Please try to add the following dependency into your pom.xml file
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

and Download lombok.jar from the given link
https://projectlombok.org/download

Now if it is zipped unzip it first and then copy it to the directory 
where you have your SpringToolSuits(STS installed).

Let say your STS version is 4.11.0.RELEASE then copy lombok.jar to STS 
directory/sts-4.11.0.RELEASE   i.e. inside STS/sts-4.11.0.RELEASE/

Now try to rebuild and update your project.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1