Updated to gradle 1.12, gradle plugin for android studio 0.10.
My project has the following structure:
3rdparty
MainProject
How to get the res folder contents of IconsetBase + Iconset1 to be merged into flavor1 and IconsetBase + Iconset2 into flavor2?
Before upgrading to new gradle this worked as the libraries (IconsetBase, Iconset1 and Iconset2) had the same package name as main
Here is my build.gradle of the main project:
buildscript {
repositories {
mavenCentral()
}
dependencies {
repositories {
mavenCentral()
}
classpath 'com.android.tools.build:gradle:0.10.0'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
useOldManifestMerger false
compileSdkVersion 19
buildToolsVersion "19.0.3"
lintOptions {
...
}
sourceSets {
main.java.srcDirs = ['src/main/java']
main.resources.srcDirs = ['src/main/res']
}
signingConfigs {
...
}
buildTypes {
...
}
// Common dependencies
dependencies {
compile project(':3rdparty:Graphics:Iconsets:IconsetBase')
}
defaultConfig {
...
}
productFlavors {
flavor1 { packageName "..."}
flavor2 { packageName "..."}
}
android.sourceSets.flavor1 {
dependencies { compile project(':3rdparty:Graphics:Iconsets:Iconset1') }
res { srcDir 'flavor1' }
resources { srcDir 'flavor1' }
}
android.sourceSets.flavor2 {
dependencies { compile project(':3rdparty:Graphics:Iconsets:Iconset2') }
res { srcDir 'flavor2' }
resources { srcDir 'flavor2' }
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:4.3.23'
}
=EDIT=
Further explanation:
What I seek is to merge resources from another location dynamically.
Background: flavor1 has base icon set with images icon1 and icon2, flavor2 has base iconset and icon1 and icon2 also, but the icons are different per icon set. Otherwise I would have to have icon1, icon2 etc. per flavor many times, and on updates /changes of those icons It must be done for every flavor existing (I have more than 20)
Could this be achieved with some custom task without libraries?
You can define a specific dependency by flavor :
productFlavors {
flavor1 {
...
dependencies {
flavor1Compile project(':iconSet1')
}
}
flavor2 {
...
dependencies {
flavor2Compile project(':iconSet2')
}
}
}
In your build the dependencies are in the SourceSets and that's wrong.
EDIT
Ok, I hope I better understand your goal now. What you can do is defining multiple resource directory for each flavor :
android {
sourceSets {
flavor1 {
res.srcDirs = ['flavor1','../3rdparty/Graphics/Iconsets/Iconset1/res']
}
flavor2 {
res.srcDirs = ['flavor2','../3rdparty/Graphics/Iconsets/Iconset2/res']
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With