-
Notifications
You must be signed in to change notification settings - Fork 743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: How to use error-prone in maven without changing the compiler? #985
Comments
@monperrus: you'd basically want to recompile the code in the <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<executions>
<execution>
<id>compile-with-error-prone</id>
<phase>verify</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-d</arg>
<arg>${project.build.directory}/classes-ep</arg>
</compilerArgs>
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<!-- Erroneously inverted logic... for details, see
https://jira.codehaus.org/browse/MCOMPILER-209 -->
<useIncrementalCompilation>true</useIncrementalCompilation>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>
</plugin> (I tested the above config by modifying an existing project, so I might have missed a detail. But it should help you on your way.) |
Thanks a lot! |
@Stephan202 and where does one exactly configure the |
@namannigam that ID can be any value; it doesn't need to be referenced anywhere else. (Well it's a bit more subtle than that, but don't worry about it.) If you're asking where this whole blob of XML should best live, I'd recommend to put it inside your parent <project ...>
...
<build>
<pluginManagement>
<plugins>
<!-- here --
</plugins>
</pluginManagement>
</build>
...
</project> But if you have a single <project ...>
...
<build>
<plugins>
<!-- here -->
</plugins>
</build>
...
</project> If that doesn't answer your question, I need some more details :) |
@Stephan202 Did you misread Please note however that this way of configure the maven-compiler-plugin to use ErrorProne won't work with Java 11+; you'd better use the new |
Doh, @tbroyer I did misread indeed! Thanks for noticing :) |
I want to use error-prone on my Java project.
However, I am reluctant to to change the compiler configuration and want to keep the normal
javac
configuration frommaven-compiler-plugin
.Basically, it means using use error-prone in the verify phase, as for instance with the findbugs or checkstyle plugin.
How to use error-prone in maven without changing the compiler?
The text was updated successfully, but these errors were encountered: