From 64b8d8130744fd0c4a61bee7c47c237c8af14feb Mon Sep 17 00:00:00 2001 From: Sagar Upadhyaya Date: Wed, 6 Apr 2022 12:31:24 -0700 Subject: [PATCH] Changing logic for clone git repo to make it compatible with gradle 7 Signed-off-by: Sagar Upadhyaya --- build.gradle | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 686ccb13..5fa16e6e 100644 --- a/build.gradle +++ b/build.gradle @@ -42,6 +42,7 @@ plugins { id 'jacoco' id 'com.diffplug.spotless' version '5.11.0' id 'checkstyle' + id 'org.ajoberstar.grgit' version '5.0.0' } spotbugsMain { @@ -327,7 +328,7 @@ gradle.startParameter.excludedTaskNames += [ "forbiddenApisMain", "testingConventions"] import java.util.concurrent.Callable -import org.ajoberstar.gradle.git.tasks.GitClone +import org.ajoberstar.grgit.Grgit import org.opensearch.gradle.test.RestIntegTestTask import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask @@ -342,16 +343,21 @@ static def propEnabled(property) { * cloneRcaGitRepo clones the performance-analyzer-rca repo if the -Dtests.enableIT=true flag is passed * to the Gradle JVM */ -task cloneRcaGitRepo(type: GitClone) { +task cloneRcaGitRepo() { def destination = file(rcaProjectDir) - uri = rcaProjectRepo - branch = rcaProjectBranch - destinationPath = destination - bare = false - enabled = cloneRcaProject && !destination.exists() // to clone only once - + def uri = rcaProjectRepo + def branch = rcaProjectBranch doFirst { - logger.info("Cloning performance-analyzer-rca into ${rcaProjectDir} from ${rcaProjectRepo}#${rcaProjectBranch}") + println "Cloning performance-analyzer-rca into ${rcaProjectDir} from ${rcaProjectRepo}#${rcaProjectBranch}" + } + doLast { + if (destination.exists() && destination.isDirectory()) { // If directory exists, use this instead. + def grgit = Grgit.open(dir: destination.toString()) + } else { // Otherwise pull it from git. + def grgit = Grgit.clone(dir: destination.toString(), uri: uri) + grgit.fetch(remote: 'origin') + grgit.checkout(branch: branch) + } } }