What is a 'resource-generating task' in An

2019-05-23 02:28发布

问题:

This reddit thread has a solution to one of my problems and this comment

...a better option is to create a task which copies the file into "$project.buildDir/readme/res/raw/", register that folder with the Android plugin as a generated resource root, and register the task with the Android plugin as resource-generating task.

seems to be suggesting a better way but I am not sure what is meant by 'register as a resource-generating task'.

回答1:

They're probably referring to variant.registerResGeneratingTask. This doesn't appear to be publicly documented so it may be subject to change, but it is used by various third-party plugins such as this one.



回答2:

Ok, think it means registering to mergeResources task like below

variant.mergeResources.doLast {
    copy {
       from ("path/to/some/file")
       into ("$outputDir/raw")
    }
}