There is an application. I prescribe dimensions in it in values-sw330dp / dimens.xml and duplicate them in sw266dp / dimens.xml with a factor of 0.8. I would like to automate this process. Is it possible to configure Gradle so that it takes values from sw330dp and creates exactly the same in sw266dp with a factor of 0.8?
- In general, the gradle script is written in the groovy language, so theoretically it is probably possible, but practically I don’t think that this idea came to anyone before you. The problem is that every time you start / debug it will be re-generated every time, and here the compilation speed of the project leaves much to be desired - pavlofff
- @pavlofff, well, this is in any case, faster than manually. Are there any thoughts / sketches for practical implementation? - BArtWell
|
1 answer
Copy task can filter files. It is more difficult (but possible) to find the necessary values in sw330dp / dimens.xml. Instead, I suggest taking the values somewhere in the gradle.properties and substitute them into both dimens.xml files with the necessary coefficients:
task sw330dp_dimens(type: Copy) { from('template') { include '**/dimens.xml' filter(ReplaceTokens, tokens: [value: vvv]) } into 'sw330dp' } task sw266dp_dimens(type: Copy) { from('template') { include '**/dimens.xml' filter(ReplaceTokens, tokens: [value: vvv*0.8]) } into 'sw266dp' }
|