I am trying to copy one file to multiple destinations through a Gradle task. I found the following in other websites but I get an ERROR while running this task.
def filesToCopy = copySpec{
from 'somefile.jar'
rename {String fileName -> 'anotherfile.jar'}
}
task copyFile(type:Copy) {
with filesToCopy {
into 'dest1/'
}
with filesToCopy {
into 'dest2/'
}
}
ERROR
No signature of method: org.gradle.api.internal.file.copy.CopySpecImpl.call() is applicable for argument types
Is there a way to copy to multiple destinations in one Gradle task?
If you really want them in one task, you do something like this:
def filesToCopy = copySpec {
from 'someFile.jar'
rename { 'anotherfile.jar' }
}
task copyFiles << {
['dest1', 'dest2'].each { dest ->
copy {
with filesToCopy
into dest
}
}
}