Writing an annotation processor for maven-processor-plugin

后端 未结 1 1756
广开言路
广开言路 2021-01-05 03:37

I am interested in writing an annotation processor for the maven-processor-plugin. I am relatively new to Maven.

Where in the project path should the processor Java

1条回答
  •  一生所求
    2021-01-05 03:52

    The easiest way is to keep your annotation processor in a separate project that you include as dependency.

    If that doesn't work for you, use this config

    Compiler Plugin:

    
        org.apache.maven.plugins
        maven-compiler-plugin
        2.3.2
        
            1.5
            1.5
        
        true
        
            
                default-compile
                true
                
                    
                    path/to/processor
                
            
            
                after-processing
                process-classes
                
                    compile
                
                false
                
                    path/to/processor
                
            
        
    
    

    Processor Plugin:

    
        org.bsc.maven
        maven-processor-plugin
        
            
                process
                
                    process
                
                compile
                
                    
                        com.yourcompany.YourProcessor
                    
                
            
        
    
    

    (Note that this must be executed between the two compile runs, so it is essential that you place this code in the pom.xml after the above maven-compiler-plugin configuration)

    Jar Plugin:

    
        org.apache.maven.plugins
        maven-jar-plugin
        2.3.1
        
            path/to/processor
        
        true
    
    

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