Today I started converting our project to use the gradle build system. I can't change the project structure, and I have different flavors, so I was wondering how I could override the sourceset for "dev" and "prod", because this apparently doesn't work:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion "17"
dependencies {
compile project(':ABS')
compile project(':google-play-services_lib')
compile project(':MergeAdapter')
compile fileTree(dir: 'libs', include: '*.jar')
}
signingConfigs {
release {
storeFile file("myapp.keystore")
storePassword "**********"
keyAlias "**********"
keyPassword "**********"
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aild.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
dev {
java.srcDirs = ['src-dev']
}
prod {
java.srcDirs = ['src-prod']
}
instrumentTest.setRoot('tests')
}
productFlavors {
dev {
packageName "com.myapp.dev"
}
prod {
packageName "com.myapp"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
This gives me the following error:
Cannot add a AndroidSourceSet with name 'dev' as a AndroidSourceSet with that name already exists.
The thing is, I can't use the new project structure and am stuck with this one, so how do I override the source directory here so it include, for the dev version, src-dev and for the prod version src-prod (instead of src/main/java and src/dev/java or src/prod/java)
Thx!
EDIT: The src-prod and src-dev directories only contain classes with constants that are used to point to different environments. I will do the same with assets (different icon for dev env)