Commit 4e13ffab authored by Florian Schäfer's avatar Florian Schäfer

Configure Errorprone the same way with Java 10 as with Java 8

parent bd707076
import com.github.spotbugs.SpotBugsTask
import net.ltgt.gradle.errorprone.javacplugin.CheckSeverity
import org.openstreetmap.josm.gradle.plugin.task.GeneratePluginList
import java.nio.file.Files
import java.nio.file.Paths
import java.time.Duration
import java.time.Instant
import org.openstreetmap.josm.gradle.plugin.task.GeneratePluginList
import com.github.spotbugs.SpotBugsTask
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.ltgt.gradle:gradle-errorprone-javacplugin-plugin:0.3"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.16"
}
}
plugins {
id "java"
......@@ -25,26 +15,32 @@ plugins {
id "com.github.ben-manes.versions" version "0.20.0"
id "com.github.spotbugs" version "1.6.2"
id "org.openstreetmap.josm" version "0.5.0"
id "net.ltgt.errorprone" version "0.0.16" apply(false)
id "net.ltgt.errorprone-javacplugin" version "0.3" apply(false)
}
// Set up Errorprone
def errorproneChecks = [
"DefaultCharset": CheckSeverity.ERROR,
"StringEquality": CheckSeverity.ERROR,
"ConstantField": CheckSeverity.WARN,
"FieldCanBeFinal": CheckSeverity.WARN,
"LambdaFunctionalInterface": CheckSeverity.WARN,
"MethodCanBeStatic": CheckSeverity.WARN,
"MultiVariableDeclaration": CheckSeverity.WARN,
"PrivateConstructorForUtilityClass": CheckSeverity.WARN,
"UngroupedOverloads": CheckSeverity.WARN,
"WildcardImport": CheckSeverity.WARN
]
if (JavaVersion.current().java9Compatible) {
apply plugin: "net.ltgt.errorprone-javacplugin"
// TODO: add the errorprone checks
} else {
apply plugin: "net.ltgt.errorprone"
tasks.withType(JavaCompile) {
options.compilerArgs += [
"-Xep:DefaultCharset:ERROR",
"-Xep:StringEquality:ERROR",
"-Xep:ConstantField:WARN",
"-Xep:FieldCanBeFinal:WARN",
"-Xep:LambdaFunctionalInterface:WARN",
"-Xep:MethodCanBeStatic:WARN",
"-Xep:MultiVariableDeclaration:WARN",
"-Xep:PrivateConstructorForUtilityClass:WARN",
"-Xep:RemoveUnusedImports:WARN",
"-Xep:UngroupedOverloads:WARN",
"-Xep:WildcardImport:WARN"
]
errorproneChecks.forEach { name, severity ->
options.compilerArgs.add("-Xep:$name:$severity")
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment