How to compile res only but not pack to apk in gradle?

There are two build types sharing the same code. And one uses lots of resources, but I don’t wanna pack the res to the other one. How can I do to compile the res only(because the res referenced in the java code)? Thanks.