Setting the generated source directory for annotation processors in Maven

前端 未结 7 1365
南方客
南方客 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:38

    I've been using the maven-processor-plugin as follows:

    
        org.bsc.maven
        maven-processor-plugin
        2.2.4
        
          
            process-my-annotations
            
              process
            
            generate-test-sources
            
              
                x.y.z.MyAnnotationProcessor
              
              ${project.build.directory}/generated-test-sources/test-annotations
              ${project.build.directory}/test-classes
            
          
        
      
    

    The generated code goes into target/generated-test-sources/test-annotations, and generated resources into target/test-classes (the default for the process goal is target/generated-sources and target/classes, respectively).

    I also need to use maven-build-helper-plugin to add target/generated-test-sources/test-annotations to the test source path so that test-compile phase will compile the generated code.

提交回复
热议问题