我在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操作呢?
There are pre-run tasks in the running configuration. The default is gradle assembly. You can add your tasks before this task.
The task of assembleDebug is executed by default when executing the app, so you only need
Just add the above code to the build.
task importHTML(type: Copy, dependOn:'assmbleDebug'), write different compilation stages in dependsOn according to your own needs
To understand the operating mechanism of gradle, it is recommended to read "gradle for android"
Recommend a blog post: Gradle basic knowledge points and common configurations