4

I have two flavors "demo" and "full", with each their own sourceSet in src/demo and src/full. This works fine.

I want now to make a third flavor that uses one of those sourceSets. How would I do that?

I tried something like:

productFlavors {
    full {
        applicationId "com.example.full"
        signingConfig signingConfigs.full
        resValue "string", "app_name", "Full"
    }
    demo {
        applicationId "com.example.demo"
        signingConfig signingConfigs.demo
        resValue "string", "app_name", "Demo"
    }
    third {
        applicationId "com.example.third"
        resValue "string", "app_name", "third"
        signingConfig signingConfigs.full
        sourceSet = "full"
    }
}
Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
  • I got a nice answer here... http://stackoverflow.com/questions/36112157/grouping-few-of-many-sourcesets-having-exactly-same-configuration/ You might want to check that alternative. It's cleaner. – Viral Patel Mar 28 '16 at 18:52

2 Answers2

2
productFlavors {
    ...
}
sourceSets.third.root = "src/full"
Stas Parshin
  • 7,973
  • 3
  • 24
  • 43
2

I found also another way of doing it:

sourceSets.third.java.srcDirs = [ "src/full" ]

this way, you can also add more sets:

sourceSets.third.java.srcDirs = [ "src/full", "src/third" ]
Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195