0

In Gradle Groovy root build.gradle I have some method defined. For example:

File[] getFiles(String path) {
    // do some filtering here and return result array
    return result
}

In module build.gradle I have some task defined which calls method above. For example:

tasks.register("copyFiles") {
    doLast {
        for (String path : pathList) {
            File[] files = getFiles(path)
            // do something with returned files
        }
    }
}

In Groovy it is all right. Now I am converting only root build.gradle to Kotlin DSL build.gradle.kts.

I have tried some attempts with setting lambda to extra properties, but without success. They usually fails with exception:

Could not find method getFiles() for arguments ...

Thanks for your advice.

1 Answers1

0
val copyFile by creating(Copy::class) 
{
        into(project.directory)
        into("path") {
            from(bootJar.get().archiveFile.get())

        } 
}

This will copy your file onto multiple locations mentioned with into()

salsinga
  • 1,957
  • 1
  • 14
  • 26