How to configure Lombok with maven-compiler-plugin?

前端 未结 7 1979
长情又很酷
长情又很酷 2020-12-15 07:12

I have a root module and submodule in maven in the project. I am trying to use Lombok. I have added


    org.projectlombok&         


        
相关标签:
7条回答
  • 2020-12-15 07:39

    This is not a direct answer to the question which seems to be solved but acts as reference for future searchers:

    If you're using Dagger (or something else) to process your annotations like

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
          <configuration>
            <annotationProcessorPaths>
              <path>
                <groupId>com.google.dagger</groupId>
                <artifactId>dagger-compiler</artifactId>
                <version>2.15</version>
              </path>
            </annotationProcessorPaths>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugin>
        ....
      </plugins>
    </build>
    

    You have to add lombok as path like

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
          <configuration>
            <annotationProcessorPaths>
              <path>
                <groupId>com.google.dagger</groupId>
                <artifactId>dagger-compiler</artifactId>
                <version>2.15</version>
              </path>
    
              <!-- SOLUTION --> 
              <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.16.20</version>
              </path>
    
    
            </annotationProcessorPaths>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugin>
        ....
      </plugins>
    </build>
    

    You still have to list lombok as provided dependency tho.

    0 讨论(0)
提交回复
热议问题