Setting the generated source directory for annotation processors in Maven

前端 未结 7 1373
南方客
南方客 2021-02-09 20:01

I\'m trying to move a build which generates sources using an annotation processor to Maven. I\'ve tried configuring the maven-compiler-plugin as follows:

    <         


        
7条回答
  •  广开言路
    2021-02-09 20:37

    I may be missing something but shouldn't you:

    1. Generate sources in target/generated-sources/annotation-processing during the generate-sources phase? The apt-maven-plugin or the maven-annotation-plugin could help.

    2. Include generated sources when compiling sources into target/classes using in the maven-compiler-plugin or the maven-build-helper-plugin?

    EDIT: Where is xxx.annotation.EnforceJavaBeansConventionsProcessor located? Don't you need to add dependencies to the configuration of the maven-annotation-plugin as documented on the Usage page?

    
      org.bsc.maven
      maven-processor-plugin
      1.0-SNAPSHOT
      
        
          process
          
            process
          
          generate-sources
          
            src/main/generated 
            
              org.bsc.apt.BeanInfoAnnotationProcessor
            
           
        
      
      
    
    

    PS: I wouldn't use src/main/generated as output directory but rather a subdirectory of target/generated-sources.

提交回复
热议问题