# Included build only for debug configuration

**URL:** https://discuss.gradle.org/t/included-build-only-for-debug-configuration/44273
**Category:** Help/Discuss
**Created:** [November 15, 2022, 8:13pm UTC](https://discuss.gradle.org/t/included-build-only-for-debug-configuration/44273 "2022-11-15T20:13:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Tomi\_Urankar](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Tomi\_Urankar](https://discuss.gradle.org/u/Tomi_Urankar)
#### Post date: [November 15, 2022, 8:13pm UTC](https://discuss.gradle.org/t/included-build-only-for-debug-configuration/44273/1 "2022-11-15T20:13:32Z")

</div>

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](https://docs.gradle.org/current/userguide/composite_builds.html#deactivate_included_build_substitutions)

Code snippets:

```gradle
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"))
...
}

```

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [November 16, 2022, 4:12pm UTC](https://discuss.gradle.org/t/included-build-only-for-debug-configuration/44273/2 "2022-11-16T16:12:41Z")

</div>

I’m not familiar with Android builds.  
But are you sure you deactivated the substitution on the correct configuration?  
Afair this setting is not transitive.  
So if the build uses a configuration that extends `releaseImplementation` then it will still use the included build.

---

<div class="post-metadata">

### Author: ![Tomi\_Urankar](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Tomi\_Urankar](https://discuss.gradle.org/u/Tomi_Urankar)
#### Post date: [November 16, 2022, 4:32pm UTC](https://discuss.gradle.org/t/included-build-only-for-debug-configuration/44273/3 "2022-11-16T16:32:51Z")

</div>

@Vampire  
I’ve also tried changing all configurations and it still does not work:

```gradle
configurations.forEach {
    it.apply {
        resolutionStrategy.useGlobalDependencySubstitutionRules.set(false)
        isCanBeConsumed = false
        isCanBeResolved = true
        attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
    }
}

```

---

<div class="post-metadata">

### Author: ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)
#### Post date: [November 16, 2022, 4:37pm UTC](https://discuss.gradle.org/t/included-build-only-for-debug-configuration/44273/4 "2022-11-16T16:37:48Z")

</div>

That only catches all configurations already existing. Instead use `configurations.all`.

---

<div class="post-metadata">

### Author: ![Tomi\_Urankar](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Tomi\_Urankar](https://discuss.gradle.org/u/Tomi_Urankar)
#### Post date: [November 18, 2022, 4:37am UTC](https://discuss.gradle.org/t/included-build-only-for-debug-configuration/44273/5 "2022-11-18T04:37:30Z")

</div>

Thank you @Vampire for the `all` advice, it helped narrow the issue down. I needed to use the `releaseRuntimeClasspath`. Now it works.
