-
Notifications
You must be signed in to change notification settings - Fork 744
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
support sbt #291
Comments
We'd like to support as many build systems as possible. But we have limited time, and the ones we already support have been a bit neglected lately. It may be a while before sbt happens. Feel free to send us a patch, though! |
Any updates here? |
In it's current state, supporting Scala code is likely to be extremely difficult. Error Prone is heavily reliant on javac's AST. Supporting other JVM languages would require a common API for ASTs and type systems. Not impossible, but definitely a massive shift from what EP currently is doing. |
@ronshapiro |
Using JDK 9+ and a recent Error Prone, it should be possible to use Error Prone as a Javac plugin: add |
@ronshapiro I mean as a sbt plugin:) |
Assuming sbt is using javac to compile Java, it should be possible to enable Error Prone using the |
Sorry to dig up an old issue, but I managed to do exactly what was suggested and wrapped it to a global sbt plugin. The code might be useful for someone who wants to try this out with sbt: // This file is $HOME/.sbt/1.0/plugins/ErrorProne.scala
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
// put these files into ./errorprone/
// https://oss.sonatype.org/content/repositories/snapshots/com/google/errorprone/error_prone_core/2.4.1-SNAPSHOT/error_prone_core-2.4.1-20201112.221044-130-with-dependencies.jar
// https://repo1.maven.org/maven2/org/checkerframework/dataflow-shaded/3.1.2/dataflow-shaded-3.1.2.jar
// https://repo1.maven.org/maven2/com/google/code/findbugs/jFormatString/3.0.0/jFormatString-3.0.0.jar
object ErrorProne extends AutoPlugin {
override def trigger = allRequirements
override def requires: sbt.Plugins = JvmPlugin
override def projectSettings = Seq(
javacOptions ++= Seq(
"-XDcompilePolicy=simple",
"-processorpath", dependencyFiles,
"-Xplugin:ErrorProne"
)
)
private def dependencyFiles = {
val home: String = sys.env.get("HOME").get
def file(name: String) = s"${home}/.sbt/1.0/plugins/errorprone/$name"
val files = List(file("error_prone_core-2.4.1-20201112.221044-130-with-dependencies.jar"),
file("dataflow-shaded-3.1.2.jar"),
file("jFormatString-3.0.0.jar"))
val filestring = files.mkString(":")
println(s"Using errorprone libs from $filestring")
filestring
}
} |
@mikavilpas is it possible to write as a project-level plugin? |
Sorry but I have not worked in scala for a couple of years now, and I don't remember much about it. |
@mikavilpas alright. anyway, thanks for providing such an example |
there is no integration with sbt
The text was updated successfully, but these errors were encountered: