How do I run annotation processing via maven 3.3?

后端 未结 1 1380
忘了有多久
忘了有多久 2020-12-21 06:25

For years, we\'ve been running the maven-processor-plugin as a separate goal (using proc:none on maven-compiler-plugin). We are finally upgrading from

1条回答
  •  情歌与酒
    2020-12-21 07:12

    You can use the maven-compiler-plugin for annotation processing because the functionality exists in javac. To do annotation processing and regular compilation in separate phases, you can do multiple executions of the plugin, one with annotation processing turned on, the other with it turned off. The configuration for that is as follows:

    
        org.apache.maven.plugins
        maven-compiler-plugin
        3.5
        
            
                process-annotations
                generate-sources
                
                    compile
                
                
                    
                        -proc:only
                        -processor
                        MyAnnotationProcessor
                    
                
            
            
                default-compile 
                compile
                
                    compile
                
                
                    
                        -proc:none
                    
                
            
        
    
    

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