Make -try xlint warning disabled by default. (#40833)
Many gradle projects specifically use the -try exclude flag, because there are many cases where auto-closeable resource ignore is never referenced in body of corresponding try statement. Suppressing this warning specifically in each case that it happens using `@SuppressWarnings("try")` would be very verbose. This change removes `-try` from any gradle project and adds it to the build plugin. Also this change removes exclude flags from gradle projects that is already specified in build plugin (for example -deprecation). Relates to #40366
This commit is contained in:
parent
5a2eb07c0e
commit
809a5f13a4
|
@ -39,7 +39,7 @@ dependencies {
|
||||||
runtime 'org.apache.commons:commons-math3:3.2'
|
runtime 'org.apache.commons:commons-math3:3.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked,-processing"
|
compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked,-processing"
|
||||||
// enable the JMH's BenchmarkProcessor to generate the final benchmark classes
|
// enable the JMH's BenchmarkProcessor to generate the final benchmark classes
|
||||||
// needs to be added separately otherwise Gradle will quote it and javac will fail
|
// needs to be added separately otherwise Gradle will quote it and javac will fail
|
||||||
compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])
|
compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])
|
||||||
|
|
|
@ -752,7 +752,7 @@ class BuildPlugin implements Plugin<Project> {
|
||||||
*/
|
*/
|
||||||
// don't even think about passing args with -J-xxx, oracle will ask you to submit a bug report :)
|
// don't even think about passing args with -J-xxx, oracle will ask you to submit a bug report :)
|
||||||
// fail on all javac warnings
|
// fail on all javac warnings
|
||||||
options.compilerArgs << '-Werror' << '-Xlint:all,-path,-serial,-options,-deprecation' << '-Xdoclint:all' << '-Xdoclint:-missing'
|
options.compilerArgs << '-Werror' << '-Xlint:all,-path,-serial,-options,-deprecation,-try' << '-Xdoclint:all' << '-Xdoclint:-missing'
|
||||||
|
|
||||||
// either disable annotation processor completely (default) or allow to enable them if an annotation processor is explicitly defined
|
// either disable annotation processor completely (default) or allow to enable them if an annotation processor is explicitly defined
|
||||||
if (options.compilerArgs.contains("-processor") == false) {
|
if (options.compilerArgs.contains("-processor") == false) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ assemble.enabled = false
|
||||||
dependencyLicenses.enabled = false
|
dependencyLicenses.enabled = false
|
||||||
dependenciesInfo.enabled = false
|
dependenciesInfo.enabled = false
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
|
compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
||||||
|
|
||||||
// no unit tests
|
// no unit tests
|
||||||
unitTest.enabled = false
|
unitTest.enabled = false
|
||||||
|
|
|
@ -29,8 +29,7 @@ esplugin {
|
||||||
hasClientJar = true
|
hasClientJar = true
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-try"
|
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// network stack
|
// network stack
|
||||||
|
|
|
@ -151,8 +151,8 @@ if (isEclipse) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
|
compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
||||||
|
|
||||||
forbiddenPatterns {
|
forbiddenPatterns {
|
||||||
exclude '**/*.json'
|
exclude '**/*.json'
|
||||||
|
|
|
@ -35,7 +35,7 @@ dependencies {
|
||||||
compile "org.elasticsearch:mocksocket:${versions.mocksocket}"
|
compile "org.elasticsearch:mocksocket:${versions.mocksocket}"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << '-Xlint:-cast,-rawtypes,-try,-unchecked'
|
compileJava.options.compilerArgs << '-Xlint:-cast,-rawtypes,-unchecked'
|
||||||
compileTestJava.options.compilerArgs << '-Xlint:-rawtypes'
|
compileTestJava.options.compilerArgs << '-Xlint:-rawtypes'
|
||||||
|
|
||||||
// the main files are actually test files, so use the appropriate forbidden api sigs
|
// the main files are actually test files, so use the appropriate forbidden api sigs
|
||||||
|
|
|
@ -15,9 +15,6 @@ archivesBaseName = 'x-pack-ccr'
|
||||||
|
|
||||||
integTest.enabled = false
|
integTest.enabled = false
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-try"
|
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-try"
|
|
||||||
|
|
||||||
// Integration Test classes that cannot run with the security manager
|
// Integration Test classes that cannot run with the security manager
|
||||||
String[] noSecurityManagerITClasses = [ "**/CloseFollowerIndexIT.class" ]
|
String[] noSecurityManagerITClasses = [ "**/CloseFollowerIndexIT.class" ]
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@ forbiddenPatterns {
|
||||||
exclude '**/*.zip'
|
exclude '**/*.zip'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
|
|
||||||
licenseHeaders {
|
licenseHeaders {
|
||||||
approvedLicenses << 'BCrypt (BSD-like)'
|
approvedLicenses << 'BCrypt (BSD-like)'
|
||||||
|
|
|
@ -26,8 +26,8 @@ dependencies {
|
||||||
testCompile "org.elasticsearch.plugin:x-pack-ilm:${version}"
|
testCompile "org.elasticsearch.plugin:x-pack-ilm:${version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
testArtifacts.extendsFrom testRuntime
|
testArtifacts.extendsFrom testRuntime
|
||||||
|
|
|
@ -123,8 +123,8 @@ dependencies {
|
||||||
testCompile('org.apache.directory.mavibot:mavibot:1.0.0-M8')
|
testCompile('org.apache.directory.mavibot:mavibot:1.0.0-M8')
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
testArtifacts.extendsFrom testRuntime
|
testArtifacts.extendsFrom testRuntime
|
||||||
|
|
|
@ -14,8 +14,8 @@ archivesBaseName = 'x-pack-watcher'
|
||||||
|
|
||||||
ext.compactProfile = 'full'
|
ext.compactProfile = 'full'
|
||||||
|
|
||||||
compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
|
|
||||||
dependencyLicenses {
|
dependencyLicenses {
|
||||||
mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer'
|
mapping from: /owasp-java-html-sanitizer.*/, to: 'owasp-java-html-sanitizer'
|
||||||
|
|
|
@ -134,7 +134,7 @@ task bwcTestSnapshots {
|
||||||
}
|
}
|
||||||
check.dependsOn(bwcTestSnapshots)
|
check.dependsOn(bwcTestSnapshots)
|
||||||
|
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
||||||
|
|
||||||
// copy x-pack plugin info so it is on the classpath and security manager has the right permissions
|
// copy x-pack plugin info so it is on the classpath and security manager has the right permissions
|
||||||
task copyXPackRestSpec(type: Copy) {
|
task copyXPackRestSpec(type: Copy) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ Closure waitWithAuth = { NodeInfo node, AntBuilder ant ->
|
||||||
return tmpFile.exists()
|
return tmpFile.exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
|
||||||
|
|
||||||
forbiddenPatterns {
|
forbiddenPatterns {
|
||||||
exclude '**/system_key'
|
exclude '**/system_key'
|
||||||
|
|
|
@ -10,7 +10,7 @@ testFixtures.useFixture ":x-pack:test:smb-fixture"
|
||||||
|
|
||||||
// add test resources from security, so tests can use example certs
|
// add test resources from security, so tests can use example certs
|
||||||
sourceSets.test.resources.srcDirs(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
|
sourceSets.test.resources.srcDirs(project(xpackModule('security')).sourceSets.test.resources.srcDirs)
|
||||||
compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked"
|
compileTestJava.options.compilerArgs << "-Xlint:-rawtypes,-unchecked"
|
||||||
|
|
||||||
// we have to repeat these patterns because the security test resources are effectively in the src of this project
|
// we have to repeat these patterns because the security test resources are effectively in the src of this project
|
||||||
forbiddenPatterns {
|
forbiddenPatterns {
|
||||||
|
|
Loading…
Reference in New Issue