Test: Fix integ test extra config files to work with more than one
Groovy does some crazy capturing when using closures inside a loop. In this case, it somehow decided the local loop variable would be modified, and so each closure was getting a wrapped value that would be updated on each loop iteration, until all the closures pointed at the last value. This change fixes the loop to extract the object to be used by the closures.
This commit is contained in:
parent
e392e0b1df
commit
0508fc3bf1
|
@ -291,9 +291,10 @@ class ClusterFormationTasks {
|
||||||
File configDir = new File(node.homeDir, 'config')
|
File configDir = new File(node.homeDir, 'config')
|
||||||
copyConfig.into(configDir) // copy must always have a general dest dir, even though we don't use it
|
copyConfig.into(configDir) // 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()) {
|
for (Map.Entry<String,Object> extraConfigFile : node.config.extraConfigFiles.entrySet()) {
|
||||||
|
Object extraConfigFileValue = extraConfigFile.getValue()
|
||||||
copyConfig.doFirst {
|
copyConfig.doFirst {
|
||||||
// make sure the copy won't be a no-op or act on a directory
|
// make sure the copy won't be a no-op or act on a directory
|
||||||
File srcConfigFile = project.file(extraConfigFile.getValue())
|
File srcConfigFile = project.file(extraConfigFileValue)
|
||||||
if (srcConfigFile.isDirectory()) {
|
if (srcConfigFile.isDirectory()) {
|
||||||
throw new GradleException("Source for extraConfigFile must be a file: ${srcConfigFile}")
|
throw new GradleException("Source for extraConfigFile must be a file: ${srcConfigFile}")
|
||||||
}
|
}
|
||||||
|
@ -303,7 +304,7 @@ class ClusterFormationTasks {
|
||||||
}
|
}
|
||||||
File destConfigFile = new File(node.homeDir, 'config/' + extraConfigFile.getKey())
|
File destConfigFile = new File(node.homeDir, 'config/' + extraConfigFile.getKey())
|
||||||
// wrap source file in closure to delay resolution to execution time
|
// wrap source file in closure to delay resolution to execution time
|
||||||
copyConfig.from({ extraConfigFile.getValue() }) {
|
copyConfig.from({ extraConfigFileValue }) {
|
||||||
// this must be in a closure so it is only applied to the single file specified in from above
|
// this must be in a closure so it is only applied to the single file specified in from above
|
||||||
into(configDir.toPath().relativize(destConfigFile.canonicalFile.parentFile.toPath()).toFile())
|
into(configDir.toPath().relativize(destConfigFile.canonicalFile.parentFile.toPath()).toFile())
|
||||||
rename { destConfigFile.name }
|
rename { destConfigFile.name }
|
||||||
|
|
Loading…
Reference in New Issue