From a896df53acea8c45b4d2de0fdf17f0f0cba9805b Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Tue, 7 Jul 2020 17:10:31 +0200 Subject: [PATCH] Remove misc dependency related deprecation warnings (7.x backport) (#59122) * Fix dependency related deprecations (#58892) * Fix classpath setup for forbiddenapi usage --- benchmarks/build.gradle | 4 +-- .../gradle/ElasticsearchJavaPlugin.java | 8 ----- modules/lang-painless/build.gradle | 4 +-- plugins/repository-hdfs/build.gradle | 2 +- server/build.gradle | 10 ++----- x-pack/plugin/sql/jdbc/build.gradle | 2 +- x-pack/plugin/sql/qa/jdbc/build.gradle | 2 +- x-pack/plugin/sql/qa/server/build.gradle | 30 +++++++++---------- x-pack/plugin/sql/sql-action/build.gradle | 6 ++-- x-pack/plugin/sql/sql-cli/build.gradle | 2 +- x-pack/plugin/sql/sql-proto/build.gradle | 2 +- x-pack/plugin/stack/qa/rest/build.gradle | 2 +- 12 files changed, 31 insertions(+), 43 deletions(-) diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 1de9a459a45..c486a6f0ea4 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -37,8 +37,8 @@ dependencies { api "org.openjdk.jmh:jmh-core:$versions.jmh" annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:$versions.jmh" // Dependencies of JMH - runtime 'net.sf.jopt-simple:jopt-simple:4.6' - runtime 'org.apache.commons:commons-math3:3.2' + runtimeOnly 'net.sf.jopt-simple:jopt-simple:4.6' + runtimeOnly 'org.apache.commons:commons-math3:3.2' } // enable the JMH's BenchmarkProcessor to generate the final benchmark classes diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java index b040e215789..59bcb4b9d66 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchJavaPlugin.java @@ -280,14 +280,6 @@ public class ElasticsearchJavaPlugin implements Plugin { compilerArgs.add(targetCompatibilityVersion.getMajorVersion()); }); }); - - project.getPluginManager().withPlugin("com.github.johnrengelman.shadow", plugin -> { - // Ensure that when we are compiling against the "original" JAR that we also include any "shadow" dependencies on the compile - // classpath - Configuration shadowConfig = project.getConfigurations().getByName(ShadowBasePlugin.getCONFIGURATION_NAME()); - Configuration apiConfig = project.getConfigurations().getByName(JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME); - shadowConfig.getDependencies().all(dependency -> apiConfig.getDependencies().add(dependency)); - }); } /** diff --git a/modules/lang-painless/build.gradle b/modules/lang-painless/build.gradle index 03b161e1206..65c0be326df 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -84,8 +84,8 @@ sourceSets { } dependencies { - docCompile project(':server') - docCompile project(':modules:lang-painless') + docImplementation project(':server') + docImplementation project(':modules:lang-painless') } testClusters { diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 963ed7fa37a..3fca721b4b8 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -71,7 +71,7 @@ dependencies { // Set the keytab files in the classpath so that we can access them from test code without the security manager // freaking out. if (isEclipse == false) { - testRuntime files(project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("hdfs", "hdfs_hdfs.build.elastic.co.keytab").parent) + testRuntimeOnly files(project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("hdfs", "hdfs_hdfs.build.elastic.co.keytab").parent) } } diff --git a/server/build.gradle b/server/build.gradle index 9457a497ba9..1c85298ce75 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -45,11 +45,11 @@ if (!isEclipse) { } configurations { - java11Compile.extendsFrom(api) + java11Implementation.extendsFrom(api) } dependencies { - java11Compile sourceSets.main.output + java11Implementation sourceSets.main.output } compileJava11Java { @@ -122,11 +122,7 @@ dependencies { // repackaged jna with native bits linked against all elastic supported platforms api "org.elasticsearch:jna:${versions.jna}" - - if (!isEclipse) { - java11Compile sourceSets.main.output - } - + testImplementation(project(":test:framework")) { // tests use the locally compiled version of server exclude group: 'org.elasticsearch', module: 'server' diff --git a/x-pack/plugin/sql/jdbc/build.gradle b/x-pack/plugin/sql/jdbc/build.gradle index 28158b9a309..3677cd7d5bd 100644 --- a/x-pack/plugin/sql/jdbc/build.gradle +++ b/x-pack/plugin/sql/jdbc/build.gradle @@ -25,7 +25,7 @@ dependencies { } api project(':libs:elasticsearch-core') api "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}" - runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" + runtimeOnly "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" testImplementation project(":test:framework") testImplementation project(path: xpackModule('core'), configuration: 'testArtifacts') } diff --git a/x-pack/plugin/sql/qa/jdbc/build.gradle b/x-pack/plugin/sql/qa/jdbc/build.gradle index d0abe3126e9..9808d8ad536 100644 --- a/x-pack/plugin/sql/qa/jdbc/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/build.gradle @@ -44,7 +44,7 @@ subprojects { } testImplementation project(":test:framework") - testRuntime project(path: xpackModule('sql:jdbc')) + testRuntimeOnly project(path: xpackModule('sql:jdbc')) } if (project.name != 'security') { diff --git a/x-pack/plugin/sql/qa/server/build.gradle b/x-pack/plugin/sql/qa/server/build.gradle index 984a7d005d2..7ea79c34438 100644 --- a/x-pack/plugin/sql/qa/server/build.gradle +++ b/x-pack/plugin/sql/qa/server/build.gradle @@ -30,7 +30,7 @@ dependencies { api "org.jline:jline-reader:${jlineVersion}" api "org.jline:jline-style:${jlineVersion}" - testRuntime "org.elasticsearch:jna:${versions.jna}" + testRuntimeOnly "org.elasticsearch:jna:${versions.jna}" } /* disable unit tests because these are all integration tests used @@ -55,7 +55,7 @@ subprojects { configurations.testRuntimeClasspath { resolutionStrategy.force "org.slf4j:slf4j-api:1.7.25" } - configurations.testRuntime { + configurations.testRuntimeOnly { // This is also required to make resolveAllDependencies work resolutionStrategy.force "org.slf4j:slf4j-api:1.7.25" } @@ -70,35 +70,35 @@ subprojects { testImplementation project(":test:framework") // JDBC testing dependencies - testRuntime "net.sourceforge.csvjdbc:csvjdbc:${csvjdbcVersion}" - testRuntime "com.h2database:h2:${h2Version}" + testRuntimeOnly "net.sourceforge.csvjdbc:csvjdbc:${csvjdbcVersion}" + testRuntimeOnly "com.h2database:h2:${h2Version}" // H2GIS testing dependencies - testRuntime("org.orbisgis:h2gis:${h2gisVersion}") { + testRuntimeOnly("org.orbisgis:h2gis:${h2gisVersion}") { exclude group: "org.locationtech.jts" exclude group: "com.fasterxml.jackson.core" } - testRuntime project(path: xpackModule('sql:jdbc')) - testRuntime xpackProject('plugin:sql:sql-client') + testRuntimeOnly project(path: xpackModule('sql:jdbc')) + testRuntimeOnly xpackProject('plugin:sql:sql-client') // CLI testing dependencies - testRuntime project(path: xpackModule('sql:sql-cli')) - testRuntime(xpackProject('plugin:sql:sql-action')) { + testRuntimeOnly project(path: xpackModule('sql:sql-cli')) + testRuntimeOnly(xpackProject('plugin:sql:sql-action')) { transitive = false } - testRuntime("org.jline:jline-terminal-jna:${jlineVersion}") { + testRuntimeOnly("org.jline:jline-terminal-jna:${jlineVersion}") { exclude group: "net.java.dev.jna" } - testRuntime "org.jline:jline-terminal:${jlineVersion}" - testRuntime "org.jline:jline-reader:${jlineVersion}" - testRuntime "org.jline:jline-style:${jlineVersion}" + testRuntimeOnly "org.jline:jline-terminal:${jlineVersion}" + testRuntimeOnly "org.jline:jline-reader:${jlineVersion}" + testRuntimeOnly "org.jline:jline-style:${jlineVersion}" - testRuntime "org.elasticsearch:jna:${versions.jna}" + testRuntimeOnly "org.elasticsearch:jna:${versions.jna}" // spatial dependency - testRuntime project(path: xpackModule('spatial')) + testRuntimeOnly project(path: xpackModule('spatial')) } if (project.name != 'security') { diff --git a/x-pack/plugin/sql/sql-action/build.gradle b/x-pack/plugin/sql/sql-action/build.gradle index 16c770df263..eaa2a485b06 100644 --- a/x-pack/plugin/sql/sql-action/build.gradle +++ b/x-pack/plugin/sql/sql-action/build.gradle @@ -21,9 +21,9 @@ dependencies { api xpackProject('plugin:sql:sql-proto') api "org.apache.lucene:lucene-core:${versions.lucene}" api "joda-time:joda-time:${versions.joda}" - runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" - runtime "org.apache.logging.log4j:log4j-api:${versions.log4j}" - runtime "org.apache.logging.log4j:log4j-core:${versions.log4j}" + runtimeOnly "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" + runtimeOnly "org.apache.logging.log4j:log4j-api:${versions.log4j}" + runtimeOnly "org.apache.logging.log4j:log4j-core:${versions.log4j}" testImplementation project(":test:framework") } diff --git a/x-pack/plugin/sql/sql-cli/build.gradle b/x-pack/plugin/sql/sql-cli/build.gradle index 40af9f5f0d4..c344347f03e 100644 --- a/x-pack/plugin/sql/sql-cli/build.gradle +++ b/x-pack/plugin/sql/sql-cli/build.gradle @@ -30,7 +30,7 @@ dependencies { api xpackProject('plugin:sql:sql-action') api project(":libs:elasticsearch-cli") api project(':libs:elasticsearch-x-content') - runtime "org.elasticsearch:jna:${versions.jna}" + runtimeOnly "org.elasticsearch:jna:${versions.jna}" testImplementation project(":test:framework") } diff --git a/x-pack/plugin/sql/sql-proto/build.gradle b/x-pack/plugin/sql/sql-proto/build.gradle index 828ee5fa694..7a86dd0ba4d 100644 --- a/x-pack/plugin/sql/sql-proto/build.gradle +++ b/x-pack/plugin/sql/sql-proto/build.gradle @@ -13,7 +13,7 @@ dependencies { api( project(':libs:elasticsearch-x-content')) { transitive = false } - runtime "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" + runtimeOnly "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" testImplementation project(":test:framework") } diff --git a/x-pack/plugin/stack/qa/rest/build.gradle b/x-pack/plugin/stack/qa/rest/build.gradle index cc94a51db26..885e9fce670 100644 --- a/x-pack/plugin/stack/qa/rest/build.gradle +++ b/x-pack/plugin/stack/qa/rest/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'elasticsearch.rest-resources' dependencies { testImplementation project(path: xpackModule('core'), configuration: 'testArtifacts') - testImplementation project(path: xpackModule('stack'), configuration: 'runtime') + testImplementation project(xpackModule('stack')) } restResources {