Android Flavors : Multiple java and src directories for each flavor

前端 未结 2 506
灰色年华
灰色年华 2020-12-20 19:13

Can anyone explain to me how I can use for each of my flavors more then just the main and the flavor specific java/src directories ? My goal is to have directories which are

相关标签:
2条回答
  • 2020-12-20 19:38

    As described here

    As mentioned above, each sourceSet can define multiple resource folders.

    You can define multiple resource folder. For example something like this:

    android {
         ...
         sourceSets {
                main {
                    //....
                    res.srcDirs = ['/src/main/res']
    
                }
                flavorA1 {
                     res.srcDirs = ['/src/flavor1/res', '/src/commonA/res']
                }
                flavorA2 {
                     res.srcDirs = ['/src/flavor2/res', '/src/commonA/res']
                }     
                //.....other flavors   
         }
    }
    
    0 讨论(0)
  • 2020-12-20 19:39

    I've found a slightly different format is required for setting java source files

    sourceSets {
        favorA1 {
            java {
                srcDirs('src/favorA1/java/src', 'src/commonA/java/src')
            }
        }
        favorA2 {
            java {
                srcDirs('src/favorA2/java/src', 'src/commonA/java/src')
            }
        }
    }
    

    Gradle Java
    Gradle Source Api

    0 讨论(0)
提交回复
热议问题