JaCoCo: exclude generated methods (using it with Lombok)

前端 未结 3 915
说谎
说谎 2021-02-05 03:08

I am using JaCoCo and it is considering methods generated by Lombok (generated in the bytecode, not trace of them in the source code). How can I configure JaCoCo to ignore them?

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 03:42

    As has already been answered, adding lombok.config in the root directory of the project solves the problem, but if you're using Maven and want to avoid adding lombok.config to your repository, you can use the Apache Maven AntRun Plugin in order to generate it automatically on build:

    
       
          org.apache.maven.plugins
          maven-antrun-plugin
          3.0.0
          
             
                lombok-config
                initialize
                
                   run
                
                
                   
                      
                         
                         
                      
                   
                
                 
             
          
       
    
    

    Don't forget to instruct your SCM to ignore this autogenerated file.

提交回复
热议问题