I have this task, which copy some files to a device
task copyTestVideos(type: Exec) {
commandLine 'adb', 'push', 'src/androidTest/raw/test1.mp4', '/mnt/sdcard/DCIM/Camera/'
commandLine 'adb', 'push', 'src/androidTest/raw/test2.mp4', '/mnt/sdcard/DCIM/Camera/'
commandLine 'adb', 'push', 'src/androidTest/raw/test3.mp4', '/mnt/sdcard/DCIM/Camera/'
commandLine 'adb', 'push', 'src/androidTest/raw/test4.mp4', '/mnt/sdcard/DCIM/Camera/'
commandLine 'adb', 'push', 'src/androidTest/raw/test5.mp4', '/mnt/sdcard/DCIM/Camera/'
commandLine 'adb', 'push', 'src/androidTest/raw/test6.mp4', '/mnt/sdcard/DCIM/Camera/'
}
turns out that only the last line seems to be executed. Anyone saw something similar?
What you are doing is configuring your Exec
task. The lines starting with commandLine
are not actually executing during the configuration phase. Instead they set property commandLine
of your task repeatedly.
During the execution phase property commandLine
is used to start the process. At this moment it only contains one value: the strings of the last line above.
See: https://docs.gradle.org/current/userguide/build_lifecycle.html#sec:build_phases
Switching to copying the folder like you did is the simplest solution in this case.