I have added the following task and its execution schedule to build.gradle
:
task copyDbFile (type: Copy)
copyDbFile {
description = 'Copies the relevant db file to assets folder'
from 'store'
into 'assets'
include '**/Test.txt'
}
preBuild {}.dependsOn copyDbFile
preBuild {}.mustRunAfter copyDbFile
I do not get any error but the Test.txt
file does not get copied to assets
folder.
I see that the task is called/executed in the gradle console
:
:clean :app:clean :app:copyDbFile UP-TO-DATE :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE ... ... ...
But the file does not get copied. I do not get any error. Have never written a gradle task before and am suspecting there is some syntax error or I missed something. But since I do not see any error i am unable to figure out.
What do you think is going wrong in the above because of which the file does not get copied to the destination folder?
The assets
and store
folders are both at same level under app
directory.
Thanks to RaGe's tips which helped me how to debug and helped me figure out that the actual problem was just that path was wrong and sice it was not finding any source file it was skipping the task.
I changed the paths in the task as follows and it worked:
task copyDbFile (type: Copy)
copyDbFile {
description = 'Copies the relevant db file to assets folder'
from 'src/main/store'
into 'src/main/assets'
include '**/*.txt'
}