我在app中的build.gradle
中定义了如下一个task:
task importHTML(type: Copy){
println('start import htmls')
from('../web')
into('./app/src/main/assets')
include('**/*')
}
我试过在右侧gradle标签下可以定义excute before Sync
,excute after Sync
等等。。
但是每次运行app的时候,都不会执行这个task,只有在Sync
和Make
的时候才有用。
如何让app每次运行的时候都去执行这个task操作呢?
阿神2017-04-17 17:45:15
There are pre-run tasks in the running configuration. The default is gradle assembly. You can add your tasks before this task.
大家讲道理2017-04-17 17:45:15
The task of assembleDebug is executed by default when executing the app, so you only need
tasks.findByName('assembleDebug').doLast {
println '++++++++ app last +++++++++'
}
Just add the above code to the build.
巴扎黑2017-04-17 17:45:15
task importHTML(type: Copy, dependOn:'assmbleDebug'), write different compilation stages in dependsOn according to your own needs
黄舟2017-04-17 17:45:15
To understand the operating mechanism of gradle, it is recommended to read "gradle for android"
PHP中文网2017-04-17 17:45:15
Recommend a blog post: Gradle basic knowledge points and common configurations