1

Assuming flavor1a, flavor1b, flavor2a, and flavor2b...

Assuming directory structure:

src

-flavor1

-flavor2

-main

Is there a simple way, in gradle, to do the following:

productFlavors {
    flavor1a {
        // Point to src/flavor1
    }
}

I can't seem to configure via sourceSets = ['src/xxxx'] in each product flavor in my build.gradle

clockwerk
  • 263
  • 3
  • 15
  • check out this accepted [answer](http://stackoverflow.com/questions/19461145/gradle-flavors-for-android-with-custom-source-sets-what-should-the-gradle-file). You'll have to change your directory structure but it seems like a better solution – Bill Jul 20 '16 at 17:55
  • The problem is that the only thing that is different between flavors is the applicationId. I don't want to duplicate the folders because it will double the footprint of my project – clockwerk Jul 20 '16 at 18:24

1 Answers1

1

Instead of configuring sourceSets within the productFlavors block, try:

productFlavors{
    flavor1{
    }
    flavor2{
    }
}

sourceSets{
    main{
        java.srcDirs = ['src/main']
        //other typical sourceSets stuff
    }

    flavor1.java.srcDirs = ['src/flavor1']
    flavor2.java.srcDirs = ['src/flavor2']
}
Bill
  • 4,506
  • 2
  • 18
  • 29