Skip to content

Commit f448561

Browse files
committed
apply build type for flavored configurations
1 parent 7e95ea3 commit f448561

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

grease/src/main/kotlin/io/deepmedia/tools/grease/configurations.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ internal fun Project.createProductFlavorConfigurations(
118118
val buildTypedSubFlavor = nameOf(subFlavor, variant.buildType.orEmpty())
119119
log.d { "Creating buildTyped sub product flavor configuration ${buildTypedSubFlavor.greasify()}..." }
120120
val config = createGrease(buildTypedSubFlavor, isTransitive)
121+
config.attributes {
122+
attribute(BuildTypeAttr.ATTRIBUTE, objects.named(BuildTypeAttr::class, variant.buildType.orEmpty()))
123+
}
121124
config.extendsFromSafely(grease(isTransitive), log)
125+
config.extendsFromSafely(greaseOf(variant.buildType.orEmpty(), isTransitive), log)
122126
config.extendsFromSafely(greaseOf(subFlavor, isTransitive), log)
123127
config.extendsFromSafely(flavorConfiguration, log)
124128
}
@@ -153,6 +157,9 @@ internal fun Project.createVariantConfigurations(
153157
) = androidComponent.onVariants { variant ->
154158
log.d { "Creating variant configuration ${variant.name.greasify()}..." }
155159
val config = createGrease(variant.name, isTransitive)
160+
config.attributes {
161+
attribute(BuildTypeAttr.ATTRIBUTE, objects.named(BuildTypeAttr::class, variant.buildType.orEmpty()))
162+
}
156163
config.extendsFromSafely(grease(isTransitive), log)
157164
config.extendsFromSafely(greaseOf(variant.buildType.orEmpty(), isTransitive), log)
158165
variant.flavorName?.let { flavor ->

tests/sample-library/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,5 @@ dependencies {
6868
// Manifest changes, layout resources
6969
grease("com.otaliastudios:cameraview:2.7.2")
7070

71-
// Doesn't work. TODO: we need to configure grease configurations so that in case of multiple matching
72-
// variants, they prefer one where com.android.build.api.attributes.BuildTypeAttr is set to release
73-
// grease(project(":sample-dependency-pure"))
71+
grease(project(":sample-dependency-pure"))
7472
}

0 commit comments

Comments
 (0)