From 52f31ee14a8c07ab1e2592abd855dc0dc05497d4 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 25 Nov 2015 00:34:56 -0800 Subject: [PATCH] Build: Allow extra config for integ test to be anything project.file() accepts This change delays the lookup for whatever is passed to extra config as the source file to happen at execution time. This allows using eg a task which generates a file, but maintains the checks that the file is not a dir and that it exists at runtime. --- .../gradle/test/ClusterFormationTasks.groovy | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 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 c5c57057f02..699d2d3aa7d 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -184,17 +184,20 @@ 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()) { - 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}") + Closure delayedSrc = { + 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}") + } + return srcConfigFile } File destConfigFile = new File(node.homeDir, 'config/' + extraConfigFile.getKey()) - copyConfig.from(srcConfigFile) - .into(destConfigFile.canonicalFile.parentFile) - .rename { destConfigFile.name } + copyConfig.from(delayedSrc) + .into(destConfigFile.canonicalFile.parentFile) + .rename { destConfigFile.name } } return copyConfig }