I’ve read chapters 1 and 2 of “Building and Testing with Gradle.” Once I encountered the Copy task, I tried to experiment with it because it would be very useful in my current project. I can’t seem to get even the most basic copy task to succeed:
task copyFiles(type: Copy) {
def folder = new File(project.projectDir.toString() + ‘/assets’)
def folder2 = new File(project.projectDir.toString() + ‘/assets2’)
println folder.exists()
println folder.toString()
println folder2.exists()
println folder2.toString()
from folder.toString()
into folder2.toString()
println “dbg1”
}
I can see both of these directories exist, however none of the contents of assets get copied into assets2. I can see all the printlns when I run any task, since it is running during the configuration phase. No errors are produced. I tried passing in -d to gradle but this task is completely silent about any errors. I understand this task should recursively process the directories and all files underneath, however like said, nothing happens.
I initially was trying to copy from the root directory of my project into a sub project—but I thought I read somewhere there’s a problem with copying into a project during the configuration phase? (which would be weird…), so I was trying to dial this back and just copy some files around…SOMEWHERE, but it doesn’t work. What am I doing wrong…?