Bart Friederichs
Bart Friederichs

Reputation: 33573

Let two flavors use the same sourceSet

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"
    }
}

Upvotes: 4

Views: 426

Answers (2)

Bart Friederichs
Bart Friederichs

Reputation: 33573

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" ]

Upvotes: 2

Stas Parshin
Stas Parshin

Reputation: 8303

productFlavors {
    ...
}
sourceSets.third.root = "src/full"

Upvotes: 2

Related Questions