Open simonharrer opened 7 years ago
I just checked Google's error-prone and was surprised to not see a rule like this. I did this more as an exercise in writing a compiler plugin than anything else. I'll look at contributing but my guess is that someone's already pitched it.
As for Gradle, you're on your own since I'm a Maven user. However, there's nothing Maven specific about the Java Compiler Plugin so it should work in Gradle. The key things to look for are being able to pass -X arg to the compiler and telling it where to find the plugin via the processor path.
Here's a Gradle blog post that covers annotation processing which is the same idea. If you get this working, provide a snippet and I'll include it in the docs.
@simonharrer To use this library with gradle, you have to configure the buildscript(s) with:
dependencies {
annotationProcessor 'com.massfords:effectively-final:1.0'
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xplugin:EffectivelyFinal"
}
}
}
@massfords I opened a pull request, changed the README with documentation about how to use with gradle.
Really cool idea to automatically detect those reassign violation; maybe could be integrated into Google's error-prone.
But my actual question is this: I was wondering how to use this in a gradle build. I didn't find any clues. Do you have any leads for this?