7

Say I have this directory structure:

app
--src
   |--main
   |   |--java
   |   |--res
   |       |--drawable
   |       |--values
   |       |--values-fr
   |       |--values-de
   |
   |--flavor1
   |   |--res
   |       |--drawable
   |
   |--flavor2
   |   |--res
   |       |--drawable
   |
   |--flavor3
       |--res
           |--drawable

values-fr is common for both flavor1 and flavor2, and so values, values-fr and values-de should get packaged

flavor3 should only package values and values-de. So I need to exclude the values-fr resource folder from the flavor3 only.

I've tried loads of combinations such as those below, but cannot figure it out, or even if it's possible.

sourceSets {
    flavor3 {
        res.exclude 'values-fr/**'
        res.exclude 'values-fr/'
    }
}

EDIT

I found this working solution to include only German for the above example using:

productFlavors {
    flavour3 {
        resConfigs 'de' // include '-de' resources, along with default 'values'
    }
}

You can also check the list of country codes from ICU here.

Fifer Sheep
  • 2,900
  • 2
  • 30
  • 47

2 Answers2

3

The final working solution is to include a language - in this case, only German (de):

productFlavors {
    flavour3 {
        resConfigs 'de' // include '-de' resources, along with default 'values'
    }
}

As a reference, you can also check the list of country codes from ICU here.

Fifer Sheep
  • 2,900
  • 2
  • 30
  • 47
0

You can exclude those folders by using this snippet:

sourceSets {
  flavor3 {
    main {
      resources {
        srcDir 'res'
        exclude '**/values-fr/**'
      }
    }
  }
}
Mike Laren
  • 8,028
  • 17
  • 51
  • 70