简体   繁体   中英

Android Gradle how to custom sourceSet in library by product flavor?

Here's my main project structure:

App/src
 - main
 - flavor1
 - flavor2
 - dimension1
 - dimension2
 - debug
 - release

Both flavor* and dimension* are flavor dimensions. The build variants are:

flavor1Dimension1Debug
flavor1Dimension2Debug
flavor2Dimension1Debug
...

And library's dir structure:

Lib/src
 - main
 - flavor2
  - DebugInterceptor.java
 - debug
  - DebugInterceptor.java
 - release
  - DebugInterceptor.java

What I want:

  • if variant contains 'flavor2', this variant should use src/flavor2/DebugInterceptor.java . It should take higher priority than build types. You can assume that these three dirs(flavor2, debug, release) contain only one file DebugInterceptor.java
  • ow merging by default build rules .

How can I configure gradle to achieve this?

use only one dimension and multiple flavor, don't use multiple dimension or remove code from dimension, dimension is not suitable for code but for other configs like api level

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM