From 84d6cbd32aa3a4c87188aa51b5c85e8fd8d4b9e8 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 24 Nov 2015 15:59:54 -0800 Subject: [PATCH] Build: Fix extra config to create a file, not a directory for the destination file Also added some checks to catch misconfiguration (dir or non existing file). --- .../gradle/test/ClusterFormationTasks.groovy | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index fe92d9cdcfe..c2dbc077ea4 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -170,8 +170,17 @@ class ClusterFormationTasks { Copy copyConfig = project.tasks.create(name: name, type: Copy, dependsOn: setup) copyConfig.into(new File(node.homeDir, 'config')) // copy must always have a general dest dir, even though we don't use it for (Map.Entry extraConfigFile : node.config.extraConfigFiles.entrySet()) { - copyConfig.from(extraConfigFile.getValue()) - .into(new File(node.homeDir, 'config/' + extraConfigFile.getKey())) + File srcConfigFile = project.file(extraConfigFile.getValue()) + if (srcConfigFile.isDirectory()) { + throw new GradleException("Source for extraConfigFile must be a file: ${srcConfigFile}") + } + if (srcConfigFile.exists() == false) { + throw new GradleException("Source file for extraConfigFile does not exist: ${srcConfigFile}") + } + File destConfigFile = new File(node.homeDir, 'config/' + extraConfigFile.getKey()) + copyConfig.from(srcConfigFile) + .into(destConfigFile.canonicalFile.parentFile) + .rename { destConfigFile.name } } copyConfig.doLast { // write elasticsearch.yml last, it cannot be overriden