This message was deleted.
# community-support
s
This message was deleted.
n
debugImplementation("com.example:library-debug:1.0.0")
releaseImplementation("com.example:library-release:1.0.0")
should work
y
Right. That's what I have now. I would like to replace that with a dependencySubstitution
first use something like that to teach Gradle that
-debug
and
-release
can't be used at the same time
then if you create a project with debug and release variants, each depending on the correct library variant, you can use that as your dependency, and anything that goes wrong will be caught
y
@ephemient do you mean similar to @Nuh Koca's suggestion?
Found a solution for this:
Copy code
allprojects {
    configurations.all {
        resolutionStrategy.dependencySubstitution {
            val substitutions = this
            substitutions.all {
                val dependency = this
                (dependency.requested as? ModuleComponentSelector)?.let {
                    if (it.group == "com.example") {
                        val buildType = attributes.getAttribute(BuildTypeAttr.ATTRIBUTE).toString()
                        val newModule = "${it.module}-$buildType"
                        dependency.useTarget(module("${it.group}:$newModule:${it.version}"))
                    }
                }
            }
        }
    }
}