I am working on a multi-module Gradle Android project, which has two flavor dimensions and a build type. What I would want to achieve is build multiple build variants by specifying only one flavor dimension and build type. I will show you the flavor dimension setting part of my build.gradle.
build.gradle
...
android {
buildTypes {
release {
debuggable false
minifyEnabled false
}
debug {
debuggable true
minifyEnabled false
}
}
flavorDimensions 'adid', 'phase'
productFlavors {
full {
dimension 'adid'
}
lite {
dimension 'adid'
}
alpha {
dimension 'phase'
versionNameSuffix '-SNAPSHOT'
}
sandbox {
dimension 'phase'
versionNameSuffix '-SNAPSHOT'
}
beta {
dimension 'phase'
versionNameSuffix '-SNAPSHOT'
}
real {
dimension 'phase'
}
}
}
...
As you can see, there are two flavor dimensions adid (2 flavors) and phase (4 flavors), and a build type (2 types), a total of 16 build variants.
- assembleLiteAlphaDebug
- assembleLiteAlphaRelease
- assembleFullAlphaDebug
- assembleFullAlphaRelease
- assembleLiteSandboxDebug
- assembleLiteSandboxRelease
- assembleFullAlphaDebug
- assembleFullAlphaRelease
Since our CI builds for a specific server phase at a time, what I would want to do is specify only one flavor and a build type in my gradle commands.
./gradlew assembleAlphaRelease // build for alpha phase
./gradlew assembleSandboxRelease // build for sandbox phase
./gradlew assembleBetaRelease // build for beta phase
./gradlew assembleRealRelease // build for real phase
I want assembleAlphaRelease to run both:
- assembleLiteAlphaRelease
- assembleFullAlphaRelease.
However, gradle does not let me do that. I can use any combination like one dimension, two dimensions, one build type two dimensions and a build type like below:
./gradlew assembleAlpha
./gradlew assembleFull
./gradlew assembleDebug
./gradlew assembleRelease
./gradlew assembeFullAlphaRelease
But whenever I combinate one flavor and a build type, gradle gives me the following error.
Task 'assembleAlphaRelease' not found in project ':app'.
I am not sure if this is intended by the Gradle plugin or a bug but was curious if anybody could give me explanations why this is not doable. :)