From ba647b4ce29b6ed1c28afe0f73ceabdcc871f7f1 Mon Sep 17 00:00:00 2001 From: Mikayla Thompson Date: Wed, 24 Apr 2024 12:56:04 -0600 Subject: [PATCH] Change gradle copy to sync to clear old jars Signed-off-by: Mikayla Thompson --- RFS/build.gradle | 2 +- .../org/opensearch/migrations/common/CommonUtils.groovy | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/RFS/build.gradle b/RFS/build.gradle index 2cc9c1477..67a3a2ec3 100644 --- a/RFS/build.gradle +++ b/RFS/build.gradle @@ -70,7 +70,7 @@ task demoPrintOutSnapshot (type: JavaExec) { mainClass = 'com.rfs.DemoPrintOutSnapshot' } -task copyDockerRuntimeJars (type: Copy) { +task copyDockerRuntimeJars (type: Sync) { description = 'Copy runtime JARs and app jar to docker build directory' // Define the destination directory diff --git a/TrafficCapture/buildSrc/src/main/groovy/org/opensearch/migrations/common/CommonUtils.groovy b/TrafficCapture/buildSrc/src/main/groovy/org/opensearch/migrations/common/CommonUtils.groovy index 02efc8637..daa9262c4 100644 --- a/TrafficCapture/buildSrc/src/main/groovy/org/opensearch/migrations/common/CommonUtils.groovy +++ b/TrafficCapture/buildSrc/src/main/groovy/org/opensearch/migrations/common/CommonUtils.groovy @@ -1,6 +1,6 @@ package org.opensearch.migrations.common -import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.Sync import org.gradle.api.Project import com.bmuschko.gradle.docker.tasks.image.Dockerfile @@ -27,7 +27,9 @@ class CommonUtils { copyArtifact(project, projectName, projectName, destDir) } static def copyArtifact(Project project, String artifactProjectName, String destProjectName, String destDir) { - project.task("copyArtifact_${destProjectName}", type: Copy) { + // Sync performs a copy, while also deleting items from the destination directory that are not in the source directory + // In our case, jars of old versions were getting "stuck" and causing conflicts when the program was run + project.task("copyArtifact_${destProjectName}", type: Sync) { dependsOn ":${artifactProjectName}:build" dependsOn ":${artifactProjectName}:jar" if (destProjectName == "trafficCaptureProxyServerTest") {