Enable java lint (#5182)

* Enable java lint

* Compile internal-lambda-java9 withot using --release flag (#34)

* Fix some custom testsets

Co-authored-by: Lauri Tulmin <tulmin@gmail.com>
This commit is contained in:
Anuraag Agrawal 2022-01-24 12:45:42 +09:00 committed by GitHub
parent c1280a9ee3
commit e04f52b9db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 3 deletions

View File

@ -43,7 +43,32 @@ java {
tasks.withType<JavaCompile>().configureEach {
with(options) {
release.set(otelJava.minJavaVersionSupported.map { it.majorVersion.toInt() })
compilerArgs.add("-Werror")
if (name != "jmhCompileGeneratedClasses") {
compilerArgs.addAll(
listOf(
"-Xlint:all",
// We suppress the "try" warning because it disallows managing an auto-closeable with
// try-with-resources without referencing the auto-closeable within the try block.
"-Xlint:-try",
// We suppress the "processing" warning as suggested in
// https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM
"-Xlint:-processing",
// We suppress the "options" warning because it prevents compilation on modern JDKs
"-Xlint:-options",
// Fail build on any warning
"-Werror"
)
)
}
encoding = "UTF-8"
if (name.contains("Test")) {
// serialVersionUID is basically guaranteed to be useless in tests
compilerArgs.add("-Xlint:-serial")
}
}
}

View File

@ -2,6 +2,19 @@ plugins {
id("otel.javaagent-instrumentation")
}
otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_1_9)
// We cannot use otelJava { minJavaVersionSupported.set(JavaVersion.VERSION_1_9) } because compiler
// will fail with -Xlint without providing an error message.
// We cannot use "--release" javac option because that will forbid calling methods added in jdk 9.
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
toolchain {
languageVersion.set(null as JavaLanguageVersion?)
}
}
tasks {
withType<JavaCompile>().configureEach {
options.release.set(null as Int?)
}
}

View File

@ -29,6 +29,8 @@ dependencies {
compileOnly("io.vertx:vertx-web:$vertxVersion")
compileOnly("io.vertx:vertx-rx-java2:$vertxVersion")
testCompileOnly("io.vertx:vertx-codegen:$vertxVersion")
testInstrumentation(project(":instrumentation:jdbc:javaagent"))
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
testInstrumentation(project(":instrumentation:rxjava:rxjava-2.0:javaagent"))

View File

@ -35,7 +35,10 @@ dependencies {
add("version3TestImplementation", "io.vertx:vertx-web:3.0.0")
add("version3TestImplementation", "io.vertx:vertx-jdbc-client:3.0.0")
add("version3TestImplementation", "io.vertx:vertx-codegen:3.0.0")
add("version3TestImplementation", "io.vertx:vertx-docgen:3.0.0")
add("latestDepTestImplementation", "io.vertx:vertx-web:4.+")
add("latestDepTestImplementation", "io.vertx:vertx-jdbc-client:4.+")
add("latestDepTestImplementation", "io.vertx:vertx-codegen:4.+")
}