Note that there are some explanatory texts on larger screens.

plurals
  1. POGradle productflavors sourcesets and old project structure
    primarykey
    data
    text
    <p>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:</p> <pre><code>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 } } } </code></pre> <p>This gives me the following error:</p> <pre><code>Cannot add a AndroidSourceSet with name 'dev' as a AndroidSourceSet with that name already exists. </code></pre> <p>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)</p> <p>Thx!</p> <p>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)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload