From abf7b2b8f2412e66c66764e66004ac4014800c06 Mon Sep 17 00:00:00 2001 From: Ralph Ursprung Date: Tue, 20 Sep 2022 10:16:39 +0200 Subject: [PATCH] use proper gradle dep. to fetch security plugin there's no need to manually construct a URL and try to fetch the artefact from there. the plugin is published on maven and we can directly use the gradle/maven dependency to fetch it. in order to more easily identify it, a new configuration type has been added: `opensearchPlugin`. for reference see the discussions on the following issues/PRs: - opensearch-project/cross-cluster-replication#274 - opensearch-project/cross-cluster-replication#455 Signed-off-by: Ralph Ursprung --- build.gradle | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index e56ddd5cf..6178014a4 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,6 @@ buildscript { opensearch_build += "-SNAPSHOT" } - // for bwc tests opensearch_previous_version = System.getProperty("bwc_older_version", "2.1.0") plugin_previous_version = opensearch_previous_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2') @@ -56,14 +55,7 @@ buildscript { common_utils_version = System.getProperty("common_utils.version", opensearch_build) kotlin_version = System.getProperty("kotlin.version", "1.6.0") - // For fetching security zip from Maven. - // https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.1.0/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-security-2.1.0.0.zip - opensearch_no_snapshot = opensearch_version.replace("-SNAPSHOT","") - security_no_snapshot = opensearch_build.replace("-SNAPSHOT","") - security_plugin_path = "build/dependencies/security" - security_plugin_download_url = 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/' + opensearch_no_snapshot + - '/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-security-' + security_no_snapshot + '.zip' - + security_plugin_version = opensearch_build.replace("-SNAPSHOT","") } repositories { @@ -126,6 +118,10 @@ configurations.all { } } +configurations { + opensearchPlugin +} + dependencies { runtimeOnly "org.opensearch:opensearch:${opensearch_version}" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" @@ -143,6 +139,8 @@ dependencies { testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:${kotlin_version}" testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" + + opensearchPlugin "org.opensearch.plugin:opensearch-security:${security_plugin_version}@zip" } repositories { @@ -212,24 +210,9 @@ static String getDebugJvmArgs(int debugPort) { return " -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${debugPort}" } -def securityPluginFile = new Callable() { - @Override - RegularFile call() throws Exception { - return new RegularFile() { - @Override - File getAsFile() { - if (new File("$project.rootDir/$security_plugin_path").exists()) { - project.delete(files("$project.rootDir/$security_plugin_path")) - } - project.mkdir security_plugin_path - ant.get(src: security_plugin_download_url, - dest: security_plugin_path, - httpusecaches: false) - return fileTree(security_plugin_path).getSingleFile() - } - } - } - } +def securityPluginFile = configurations.opensearchPlugin.resolvedConfiguration.resolvedArtifacts + .find { ResolvedArtifact f -> f.name.contains('opensearch-security') } + .file // Clone of WaitForHttpResource with updated code to support Cross cluster usecase class CrossClusterWaitForHttpResource {