Our Android project is using the standard debug and release configurations.
What we’d like to achieve is that if the build is started using assembleDebug
then the included build is used. Otherwise if the build is started using assembleRelease
then dependency from maven artifact is used.
In Gradle’s docs is a sample how to achieve this, but it is not working. As in if the includedBuild is not commented out Gradle will still use it instead of the Maven artifact when doing an assembleRelease
.
Gradle doc link:
https://docs.gradle.org/current/userguide/composite_builds.html#deactivate_included_build_substitutions
Code snippets:
SETTINGS.GRADLE
// Foo modules
includeBuild("foo.bardevkit.android")
BUILD.GRADLE
configurations.releaseImplementation{
resolutionStrategy.useGlobalDependencySubstitutionRules.set(false)
isCanBeConsumed = false
isCanBeResolved = true
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
}
dependencies {
releaseImplementation("com.foo.sdk:foo-sdk:${libs.versions.sdkVersionName.get()}-SNAPSHOT")
debugImplementation(project(":foo-sdk"))
...
}