I have a custom task that needs a directory to be created under build directory.
task customTask() {
File newDir = new File("$buildDir/newDir")
newDir.mkdirs();
//do rest of the things
}
I have made compileJava dependsOn customTask. If i run gradle build or gradle customTask, i seem to have no issues. If i do gradle clean build, the directory is not getting created and the rest of the task fails.
I dont have this issue if i change my code to the following by marking the task as doLast.
task customTask() << {
File newDir = new File("$buildDir/newDir")
newDir.mkdirs();
//do rest of the things
}
can someone please explain the behavior?