Hi,
I want to set the destinationDir at runtime for Copy task.
Here is the scenario I am trying:
I have on text file where I am specifying the list of files. Content of temp.lst :
/*<Directory Name> : <File Name> : <Directory Path> */
#DIR1: abc.h : /DIR1/inc/
#DIR1 : pqr.h : /DIR1/inc/
#DIR2 : xyz.h : /DIR2/inc/
Here I want to copy the abc.h and pqr.h to DIR1/inc, similarly copy the xyz.h to DIR2 . ( Depends on the first string of each line) I am splitting the line with separator as " : " and I want destination Path to be dynamic depends on the first word of each line.
Below is the Task I am using to copy these listed file:
task copyListedFiles (type: Copy) {
def gdkFile = new File ("${projectDir}/temp.lst")
if(gdkFile.exists())
{
gdkFile.splitEachLine(/\s:\s/) { item ->
if(!item.isEmpty())
{
if(item[0] == "#DIR1")
{
from item[1]
def destPath = "${gls_root}/" + item[2]
into destPath
}
if(item[0] == "#DIR2")
{
from item[1]
def destPath = "${gls_root}/" + item[2]
into destPath
}
}
}
}
}
The problem I am seeing here is, it is always coping all listed files in temp.lst to the DIR2 directory.
Could you please help me to resolve this issue.
Please let me know if you need more information.
Thanks Mandar