Annotation processor output in maven

后端 未结 2 1229
悲哀的现实
悲哀的现实 2021-01-11 12:10

I\'m using JSR 269 as a way to analyze code during compilation and to fail it if needed. I\'m having troubles with displaying output of my annotation processor in maven (Ant

相关标签:
2条回答
  • 2021-01-11 12:54

    I think you are running into a Maven bug or better a bug in the compiler plugin - MCOMPILER-66. When it comes to annotation processing the compiler plugin has several problems, eg also MCOMPILER-62. Really the best option imo is to disable annotation processing for the compiler plugin and use the maven-processor-plugin. In this blog post you can see how to use it. It looks like this:

       <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArgument>-proc:none</compilerArgument>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.bsc.maven</groupId>
            <artifactId>maven-processor-plugin</artifactId>
            <version>1.3.7</version>
            <executions>
                <execution>
                    <id>process</id>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <phase>process-sources</phase>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-jpamodelgen</artifactId>
                    <version>1.1.0.Final</version>
                    <scope>compile</scope>
                </dependency>
            </dependencies>
        </plugin>
    

    Note also how the annotation processor dependency is nicely scoped to the plugin only.

    0 讨论(0)
  • 2021-01-11 12:59

    You can do this by enabling showWarnings flag in the maven-compiler-plugin configuration:

    <build>
      <plugins>
        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
             <showWarnings>true</showWarnings>
           </configuration>
        </plugin>
      </plugins>
    </build>
    

    See also https://github.com/Cosium/annotation-processor-logger#enable-all-logging-levels

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