I’ve created a Groovy function that needs to use some standard JRE stuff. At first I had it in my root build.gradle, but I couldn’t import the needed package. So I created a groovy file in buildSrc which can import java.nio.file.Files and compiles correctly. However now my sub-projects can’t refer to the method in this Groovy file.
What is the right way to define a method like this and make it available to all sub-projects?
import java.nio.file.Files
void bundleApks(project, files) {
println "project name: ${project.name}"
files.each { f->
println "file name: ${f.path}"
def dest = f.path.contains('debug') ? 'debug' : 'release'
def destDir = file("$bundleDir/$dest")
Files.copy(f.path, destDir.path)
}
}