From 9ddbef0641f70ae6bb53f44e757376b341929eac Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 7 Dec 2017 19:04:40 +0100 Subject: [PATCH] Fix long path issue of bwc checkouts on Windows (elastic/x-pack-elasticsearch#3259) Hopefully fixes the Windows CI failures that break on cloning the repository into a target directory with a lengthy path name. Original commit: elastic/x-pack-elasticsearch@fe18e95d3f03fbe03b6f4004c0f5894f4373141d --- .../bwc-snapshot-dummy-projects/build.gradle | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/plugin/bwc-snapshot-dummy-projects/build.gradle b/plugin/bwc-snapshot-dummy-projects/build.gradle index c31174202ae..ba676471d62 100644 --- a/plugin/bwc-snapshot-dummy-projects/build.gradle +++ b/plugin/bwc-snapshot-dummy-projects/build.gradle @@ -1,7 +1,9 @@ +import org.apache.tools.ant.taskdefs.condition.Os import org.elasticsearch.gradle.Version import java.util.regex.Matcher import org.elasticsearch.gradle.LoggedExec +import org.elasticsearch.gradle.test.NodeInfo /** * Subdirectories of this project are dummy projects which does a local @@ -26,18 +28,35 @@ subprojects { build.dependsOn.remove('assemble') File esCheckoutDir = file("${buildDir}/bwc/checkout-es-${bwcBranch}") + /* Delay building the path as the path will not exist during configuration which will + * fail on Windows due to getting the short name requiring the path to already exist. + */ + Object esCheckoutPath = """${-> + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + NodeInfo.getShortPathName(esCheckoutDir.toString()) + } else { + esCheckoutDir.toString() + } + }""" File xpackCheckoutDir = file("${esCheckoutDir}-extra/x-pack-elasticsearch") + Object xpackCheckoutPath = """${-> + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + NodeInfo.getShortPathName(xpackCheckoutDir.toString()) + } else { + xpackCheckoutDir.toString() + } + }""" final String remote = System.getProperty("tests.bwc.remote", "elastic") task createElasticsearchClone(type: LoggedExec) { onlyIf { esCheckoutDir.exists() == false } - commandLine = ['git', 'clone', rootDir, esCheckoutDir] + commandLine = ['git', 'clone', rootDir, esCheckoutPath] } task createXPackClone(type: LoggedExec) { onlyIf { xpackCheckoutDir.exists() == false } - commandLine = ['git', 'clone', project(':x-pack-elasticsearch').projectDir, xpackCheckoutDir] + commandLine = ['git', 'clone', project(':x-pack-elasticsearch').projectDir, xpackCheckoutPath] } // we use regular Exec here to ensure we always get output, regardless of logging level