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).
This commit is contained in:
Ryan Ernst 2015-11-24 15:59:54 -08:00
parent b30db5d676
commit 84d6cbd32a
1 changed files with 11 additions and 2 deletions

View File

@ -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<String,Object> 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