Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4833

Gradle project not triggering Lombok annotation processor anymore in 12.1

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 12.1
    • None
    • None
    • None
    • Ubuntu 18.04, openjdk 13, Netbeans 12.1, gradle 6.6.1 (installed by Netbeans)

    Description

      Description:

      A Gradle project using the Lombok plugin doesn't seem to trigger the annotation processor anymore in 12.1. It worked with previous version.

      How to reproduce:

      • In 12.1, create a new "Java Application" project using Gradle.
      • Alter the gradle file, {{build.gradle, }}to add a reference to the lombok gradle plugin:

       

      plugins {
          id "io.freefair.lombok" version "5.2.1"
      }
      apply plugin: 'java'
      apply plugin: 'jacoco'
      apply plugin: 'application'mainClassName = 'gradleproject1.Main'
      
      repositories {
          jcenter()
      }
      dependencies {
          testImplementation     'junit:junit:4.13'
      }
      

       

       

      • Alter the Main.java file to make some use of a Lombok annotation:

       

      /*
       * To change this license header, choose License Headers in Project Properties.
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      package gradleproject1;
      
      import lombok.Getter;
      /**
       *
       * @author nico
       */
      public class Main {
          
          public static class TestClass {
              @Getter String testString = "hello";
          }
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              TestClass x = new TestClass();
              System.out.println(x.getTestString());
          }
          
      }
      
      

       

      Result: The project compiles and executes correctly. Unfortunately Netbeans identifies this line as an error:

       System.out.println(x.getTestString());
      

      This is due to the Lombok annotation processor not being run before checking for errors.

      By looking at the properties of the project we can see that the lombok jar file was correctly detected by Netbeans as it can be found in the "Sources > Main > Annotation Processors" tab. But somehow it doesn't seem to be used by Netbeans before checking errors.

      I tested the same procedure in 12.0 and it doesn't yield the same problem. That line is not identified as a compilation error.

      I do not know any kind of workaround for this problem. For normal Netbeans projects it is possible to manually enable the annotation processor in the properties of the project but it is not possible for Gradle projects. This basically makes Netbeans 12.1 unsuitable to work on projects using both Gradle and Lombok as far a I know. (If someone find a workaround I would be very glad.)

      Expected Behavior:

      That Netbeans properly triggers the annotation processor with Gradle projects, like it does in versions prior to 12.1.

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              nicolas-van Nicolas Vanhoren
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: