From e40bd8c2913c532fd428351266972a7086b069f7 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Tue, 9 Apr 2024 17:14:07 +0800 Subject: [PATCH] Implement support for `resource_sets` API in bazel-common --- WORKSPACE | 2 +- build.gradle | 4 +- flavors/sample-android-flavor/BUILD.bazel | 46 +++++++---- .../grab/grazel/bazel/rules/AndroidRules.kt | 8 +- .../grazel/migrate/android/AndroidData.kt | 19 ++--- .../migrate/android/AndroidExtractor.kt | 34 ++------- .../migrate/android/AndroidLibraryData.kt | 23 ++++-- .../grazel/migrate/android/AndroidTarget.kt | 10 +-- .../grab/grazel/migrate/android/SourceSet.kt | 65 ++++++++++++++-- .../target/AndroidBinaryTargetBuilder.kt | 4 +- .../target/AndroidLibraryTargetBuilder.kt | 4 +- .../DefaultAndroidLibraryDataExtractorTest.kt | 33 ++++++++ keystore/BUILD.bazel | 15 ++-- sample-android/BUILD.bazel | 76 ++++++++++--------- 14 files changed, 221 insertions(+), 122 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 33d1929f..912dad8d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -27,7 +27,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( name = "grab_bazel_common", - commit = "e68539fe1df4eff9c613bd78a6003c6dad9a0018", + commit = "77f924900d1931ef531131132bdfe4842695a030", remote = "https://github.com/grab/grab-bazel-common.git", ) diff --git a/build.gradle b/build.gradle index 12cd6c14..458c2454 100644 --- a/build.gradle +++ b/build.gradle @@ -93,7 +93,7 @@ grazel { rules { bazelCommon { gitRepository { - commit = "e68539fe1df4eff9c613bd78a6003c6dad9a0018" + commit = "77f924900d1931ef531131132bdfe4842695a030" remote = "https://github.com/grab/grab-bazel-common.git" } toolchains { @@ -169,7 +169,7 @@ idea { module { excludeDirs += [ file("bazel-bin"), - file("bazel-grazel"), + file("bazel-" + projectDir.name), file("bazel-cache"), file("bazel-out"), file("bazel-testlogs"), diff --git a/flavors/sample-android-flavor/BUILD.bazel b/flavors/sample-android-flavor/BUILD.bazel index 7670c152..36189e80 100644 --- a/flavors/sample-android-flavor/BUILD.bazel +++ b/flavors/sample-android-flavor/BUILD.bazel @@ -18,12 +18,17 @@ android_library( "generated_value": "generated", }, }, - resources = { - "src/demo/res": { + resource_sets = { + "demo": { + "res": "src/demo/res", }, - "src/free/res": { + "free": { + "res": "src/free/res", }, - "src/main/res": { + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [ @@ -58,10 +63,14 @@ android_library( "generated_value": "generated", }, }, - resources = { - "src/demo/res": { + resource_sets = { + "demo": { + "res": "src/demo/res", }, - "src/main/res": { + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [ @@ -96,12 +105,17 @@ android_library( "generated_value": "generated", }, }, - resources = { - "src/full/res": { + resource_sets = { + "full": { + "res": "src/full/res", }, - "src/free/res": { + "free": { + "res": "src/free/res", }, - "src/main/res": { + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [ @@ -136,10 +150,14 @@ android_library( "generated_value": "generated", }, }, - resources = { - "src/full/res": { + resource_sets = { + "full": { + "res": "src/full/res", }, - "src/main/res": { + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [ diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/bazel/rules/AndroidRules.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/bazel/rules/AndroidRules.kt index f6c46514..aebc1efc 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/bazel/rules/AndroidRules.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/bazel/rules/AndroidRules.kt @@ -133,7 +133,7 @@ internal fun StatementsBuilder.androidBinary( enableCompose: Boolean = false, visibility: Visibility = Visibility.Public, resourceFiles: List = emptyList(), - resources: Assignee? = null, + resourceSets: Assignee? = null, resValuesData: ResValuesData, deps: List, assetsGlob: List = emptyList(), @@ -172,7 +172,7 @@ internal fun StatementsBuilder.androidBinary( resConfigFilters.notEmpty { "resource_configuration_filters" `=` resConfigFilters.quote } - resources?.let { "resources" `=` resources } + resourceSets?.let { "resource_sets" `=` resourceSets } deps.notEmpty { "deps" `=` array(deps.map(BazelDependency::toString).quote) } @@ -199,7 +199,7 @@ internal fun StatementsBuilder.androidLibrary( manifest: String? = null, srcsGlob: List = emptyList(), visibility: Visibility = Visibility.Public, - resources: Assignee? = null, + resorceSets: Assignee? = null, resourceFiles: List = emptyList(), enableDataBinding: Boolean = false, enableCompose: Boolean = false, @@ -226,7 +226,7 @@ internal fun StatementsBuilder.androidLibrary( transform = Assignee::asString ) } - resources?.let { "resources" `=` resources } + resorceSets?.let { "resource_sets" `=` resorceSets } deps.notEmpty { "deps" `=` array(deps.map(BazelDependency::toString).map(String::quote)) } diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidData.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidData.kt index 9fbc211c..9076a2a0 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidData.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidData.kt @@ -20,13 +20,18 @@ import com.grab.grazel.bazel.rules.Multidex import com.grab.grazel.bazel.starlark.BazelDependency import com.grab.grazel.bazel.starlark.LintConfigs +internal data class BazelSourceSet( + val name: String, + val res: String?, + val assets: String?, + val manifest: String?, +) + internal interface AndroidData { val name: String val srcs: List - val res: List + val resourceSets: Set val resValuesData: ResValuesData - val assets: List - val assetsDir: String? val manifestFile: String? // Custom package used for detecting Java/Kotlin sources root @@ -46,10 +51,8 @@ internal interface AndroidData { internal data class AndroidLibraryData( override val name: String, override val srcs: List = emptyList(), - override val res: List = emptyList(), + override val resourceSets: Set = emptySet(), override val resValuesData: ResValuesData = ResValuesData(), - override val assets: List = emptyList(), - override val assetsDir: String? = null, override val manifestFile: String? = null, override val customPackage: String, override val packageName: String, @@ -65,10 +68,8 @@ internal data class AndroidLibraryData( internal data class AndroidBinaryData( override val name: String, override val srcs: List = emptyList(), - override val res: List = emptyList(), + override val resourceSets: Set = emptySet(), override val resValuesData: ResValuesData = ResValuesData(), - override val assets: List = emptyList(), - override val assetsDir: String? = null, override val manifestFile: String? = null, override val customPackage: String, override val packageName: String, diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidExtractor.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidExtractor.kt index e8479647..41193fba 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidExtractor.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidExtractor.kt @@ -18,11 +18,9 @@ package com.grab.grazel.migrate.android import com.android.build.gradle.BaseExtension import com.android.build.gradle.api.AndroidSourceSet -import com.android.build.gradle.internal.dsl.LintOptions import com.grab.grazel.GrazelExtension import com.grab.grazel.bazel.rules.Multidex import com.grab.grazel.bazel.starlark.BazelDependency -import com.grab.grazel.bazel.starlark.LintConfigs import com.grab.grazel.gradle.ConfigurationScope.BUILD import com.grab.grazel.gradle.dependencies.BuildGraphType import com.grab.grazel.gradle.dependencies.DependenciesDataSource @@ -36,10 +34,7 @@ import com.grab.grazel.gradle.variant.AndroidVariantDataSource import com.grab.grazel.gradle.variant.MatchedVariant import com.grab.grazel.gradle.variant.getMigratableBuildVariants import com.grab.grazel.gradle.variant.nameSuffix -import com.grab.grazel.migrate.android.PathResolveMode.DIRECTORY -import com.grab.grazel.migrate.android.SourceSetType.ASSETS import com.grab.grazel.migrate.android.SourceSetType.JAVA_KOTLIN -import com.grab.grazel.migrate.android.SourceSetType.RESOURCES import com.grab.grazel.migrate.dependencies.calculateDirectDependencyTags import com.grab.grazel.migrate.kotlin.kotlinParcelizeDeps import dagger.Lazy @@ -105,7 +100,6 @@ constructor( matchedVariant: MatchedVariant, extension: BaseExtension, deps: List, - sourceSetType: SourceSetType = JAVA_KOTLIN ): AndroidLibraryData { // Only consider source sets from migratable variants val migratableSourceSets = matchedVariant.variant.sourceSets @@ -115,13 +109,14 @@ constructor( extension, migratableSourceSets ) ?: "" - val srcs = androidSources(migratableSourceSets, sourceSetType).toList() - val res = androidSources(migratableSourceSets, RESOURCES, DIRECTORY).toList().reversed() + val srcs = androidSources(migratableSourceSets, JAVA_KOTLIN).toList() - val assets = androidSources(migratableSourceSets, ASSETS).toList() - val assetsDir = assetsDirectory(migratableSourceSets, assets) + val resourceSets = migratableSourceSets.flatMap { it.toResourceSet(project) } + .reversed() + .toSet() - val manifestFile = androidManifestParser.androidManifestFile(migratableSourceSets) + val manifestFile = androidManifestParser + .androidManifestFile(migratableSourceSets) ?.let(::relativePath) val tags = if (grazelExtension.rules.kotlin.enabledTransitiveReduction) { @@ -133,9 +128,7 @@ constructor( return AndroidLibraryData( name = name + matchedVariant.nameSuffix, srcs = srcs, - res = res, - assets = assets, - assetsDir = assetsDir, + resourceSets = resourceSets, manifestFile = manifestFile, customPackage = packageName, packageName = packageName, @@ -148,19 +141,6 @@ constructor( lintConfigs = lintConfigs ) } - - private fun Project.assetsDirectory( - sourceSets: List, - assets: List - ): String? { - return if (assets.isNotEmpty()) { - val assetItem = assets.first() - sourceSets - .flatMap { it.assets.srcDirs } - .map { relativePath(it) } - .first { assetItem.contains(it) } - } else null - } } internal interface AndroidBinaryDataExtractor : AndroidExtractor diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidLibraryData.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidLibraryData.kt index ff0f4a61..a973e222 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidLibraryData.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidLibraryData.kt @@ -38,14 +38,25 @@ internal fun StatementsBuilder.buildResFiles( } internal fun buildResources( - resDirs: List, -) = if (resDirs.isEmpty()) null else + resourceSets: Set, +) = if (resourceSets.isEmpty()) null else Assignee { add( - statement = resDirs - .groupBy { it } - .mapValues { emptyMap() } - .toObject(quoteKeys = true, quoteValues = true, allowEmpty = true) + statement = resourceSets.groupBy( + keySelector = { it.name }, + valueTransform = { + mapOf( + "res" to it.res, + "assets" to it.assets, + "manifest" to it.manifest + ) + }) + .mapValues { it.value.first() } + .toObject( + quoteKeys = true, + quoteValues = true, + allowEmpty = false + ) ) } diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidTarget.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidTarget.kt index d0e6af90..c2fd0e59 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidTarget.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidTarget.kt @@ -29,7 +29,7 @@ internal interface AndroidTarget : BazelBuildTarget { val enableDataBinding: Boolean val enableCompose: Boolean val projectName: String - val resDirs: List + val resourceSets: Set val resValuesData: ResValuesData val buildConfigData: BuildConfigData val packageName: String @@ -48,7 +48,7 @@ internal data class AndroidLibraryTarget( override val enableDataBinding: Boolean = false, override val enableCompose: Boolean = false, override val projectName: String = name, - override val resDirs: List, + override val resourceSets: Set = emptySet(), override val resValuesData: ResValuesData = ResValuesData(), override val buildConfigData: BuildConfigData = BuildConfigData(), override val packageName: String, @@ -66,7 +66,7 @@ internal data class AndroidLibraryTarget( enableDataBinding = enableDataBinding, enableCompose = enableCompose, srcsGlob = srcs, - resources = buildResources(resDirs), + resorceSets = buildResources(resourceSets), visibility = visibility, deps = deps, tags = tags, @@ -88,7 +88,7 @@ internal data class AndroidBinaryTarget( override val enableDataBinding: Boolean = false, override val enableCompose: Boolean = false, override val projectName: String = name, - override val resDirs: List, + override val resourceSets: Set = emptySet(), override val resValuesData: ResValuesData = ResValuesData(), override val buildConfigData: BuildConfigData = BuildConfigData(), override val packageName: String, @@ -123,7 +123,7 @@ internal data class AndroidBinaryTarget( manifest = manifest, manifestValues = manifestValues, resConfigFilters = resConfigFilters, - resources = buildResources(resDirs), + resourceSets = buildResources(resourceSets), resValuesData = resValuesData, deps = deps, assetsGlob = assetsGlob, diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/SourceSet.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/SourceSet.kt index 2887919e..9ec94cfd 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/SourceSet.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/SourceSet.kt @@ -17,7 +17,14 @@ package com.grab.grazel.migrate.android import com.android.build.gradle.api.AndroidSourceSet -import com.grab.grazel.migrate.android.PathResolveMode.* +import com.android.build.gradle.internal.utils.toImmutableSet +import com.grab.grazel.migrate.android.PathResolveMode.DIRECTORY +import com.grab.grazel.migrate.android.PathResolveMode.FILES +import com.grab.grazel.migrate.android.SourceSetType.ASSETS +import com.grab.grazel.migrate.android.SourceSetType.JAVA +import com.grab.grazel.migrate.android.SourceSetType.JAVA_KOTLIN +import com.grab.grazel.migrate.android.SourceSetType.KOTLIN +import com.grab.grazel.migrate.android.SourceSetType.RESOURCES import com.grab.grazel.util.commonPath import org.gradle.api.Project import java.io.File @@ -51,6 +58,52 @@ enum class PathResolveMode { FILES } +internal fun AndroidSourceSet.toResourceSet( + project: Project +): Set { + val manifestPath = manifest.srcFile.takeIf { it.exists() }?.let(project::relativePath) + + fun File.isValid() = exists() && walk().any() + val resources = res.srcDirs.filter(File::isValid) + val assets = assets.srcDirs.filter(File::isValid) + + return if (resources.size == 1 && assets.size == 1) { + // Happy path, most modules would be like this with one single res and assets dir. + setOf( + BazelSourceSet( + name = name, + res = project.relativePath(resources.first()), + assets = project.relativePath(assets.first()), + manifest = manifestPath + ) + ) + } else { + // Special case: res and assets have custom dirs, hence manually map each of them as a source + // set dir for Bazel. + return LinkedHashSet().apply { + resources.mapIndexedTo(this) { index, resDir -> + val sourceSetManifest = if (index == 0) manifestPath else null + BazelSourceSet( + name = name, + res = project.relativePath(resDir), + assets = null, + manifest = sourceSetManifest, + ) + } + assets.mapIndexedTo(this) { index, assets -> + val sourceSetManifest = if (index == 0) manifestPath else null + BazelSourceSet( + name = name, + res = null, + assets = project.relativePath(assets), + manifest = sourceSetManifest, + ) + } + }.toImmutableSet() + } +} + + /** * Given a list of directories specified by `dirs` and list of file patterns specified by `patterns` * will return list of `dir/pattern` where `dir`s has at least one file matching the pattern. @@ -96,17 +149,15 @@ internal fun Project.androidSources( ): Sequence { val sourceSetChoosers: AndroidSourceSet.() -> Sequence = when (sourceSetType) { - SourceSetType.JAVA, SourceSetType.JAVA_KOTLIN, SourceSetType.KOTLIN -> { + JAVA, JAVA_KOTLIN, KOTLIN -> { { java.srcDirs.asSequence() } } - SourceSetType.RESOURCES -> { - { - res.srcDirs.asSequence() - } + RESOURCES -> { + { res.srcDirs.asSequence() } } - SourceSetType.ASSETS -> { + ASSETS -> { { assets.srcDirs .asSequence() diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidBinaryTargetBuilder.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidBinaryTargetBuilder.kt index 44283a11..1c1e8e30 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidBinaryTargetBuilder.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidBinaryTargetBuilder.kt @@ -120,10 +120,8 @@ constructor( manifest = androidLibraryData.manifestFile, manifestValues = androidBinaryData.manifestValues, resConfigFilters = androidBinaryData.resConfigs, - resDirs = androidLibraryData.res, + resourceSets = androidLibraryData.resourceSets, resValuesData = androidLibraryData.resValuesData, - assetsGlob = androidLibraryData.assets, - assetsDir = androidLibraryData.assetsDir, buildConfigData = androidLibraryData.buildConfigData, lintConfigs = androidLibraryData.lintConfigs, ) diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidLibraryTargetBuilder.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidLibraryTargetBuilder.kt index 623ea969..166fa540 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidLibraryTargetBuilder.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/target/AndroidLibraryTargetBuilder.kt @@ -90,7 +90,7 @@ constructor( private fun AndroidLibraryData.toAndroidLibTarget() = AndroidLibraryTarget( name = name, srcs = srcs, - resDirs = res, + resourceSets = resourceSets, deps = deps, enableDataBinding = databinding, enableCompose = compose, @@ -98,8 +98,6 @@ private fun AndroidLibraryData.toAndroidLibTarget() = AndroidLibraryTarget( buildConfigData = buildConfigData, packageName = packageName, manifest = manifestFile, - assetsGlob = assets, - assetsDir = assetsDir, tags = tags, lintConfigs = lintConfigs ) diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt index aac1c1df..0714b182 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt @@ -14,12 +14,14 @@ import com.grab.grazel.gradle.variant.MatchedVariant import com.grab.grazel.util.addGrazelExtension import com.grab.grazel.util.createGrazelComponent import com.grab.grazel.util.doEvaluate +import com.grab.grazel.util.truth import org.gradle.api.Project import org.gradle.api.provider.Provider import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.the import org.junit.Test +import java.nio.file.Files import kotlin.test.assertEquals class DefaultAndroidLibraryDataExtractorTest { @@ -37,6 +39,7 @@ class DefaultAndroidLibraryDataExtractorTest { it.addGrazelExtension() } appProject = buildProject("android", rootProject) + createSources() libraryProject = buildProject("lib", rootProject) with(appProject) { with(plugins) { @@ -87,6 +90,16 @@ class DefaultAndroidLibraryDataExtractorTest { )) } + private fun createSources() { + val resMain = appProject.file("src/main/res") + resMain.toPath().let { + Files.createDirectories(it) + val values = it.resolve("values") + Files.createDirectories(values) + values.resolve("values.xml").toFile().writeText("") + } + } + private fun debugVariant(): MatchedVariant { val variant = appProject.the() .applicationVariants @@ -125,4 +138,24 @@ class DefaultAndroidLibraryDataExtractorTest { androidLibraryDataExtractor.extract(appProject, debugVariant()).databinding ) } + + @Test + fun `assert resource sets are calulcated for android binary only when file exists`() { + configure() + val resourceSets = androidLibraryDataExtractor + .extract(appProject, debugVariant()) + .resourceSets + resourceSets.truth { + containsExactly( + BazelSourceSet( + name = "main", + res = "src/main/res", + assets = null, + manifest = null + ) + ) + containsNoDuplicates() + hasSize(1) + } + } } \ No newline at end of file diff --git a/keystore/BUILD.bazel b/keystore/BUILD.bazel index bb11ee34..a44148b1 100644 --- a/keystore/BUILD.bazel +++ b/keystore/BUILD.bazel @@ -1,9 +1,10 @@ filegroup( - name = "debug-keystore", - srcs = [ - "debug.keystore", - ], - visibility = [ - "//visibility:public", - ], + name = "debug-keystore", + srcs = [ + "debug.keystore", + ], + visibility = [ + "//visibility:public", + ] ) + diff --git a/sample-android/BUILD.bazel b/sample-android/BUILD.bazel index be13df6c..d19ffd6b 100644 --- a/sample-android/BUILD.bazel +++ b/sample-android/BUILD.bazel @@ -7,10 +7,6 @@ android_binary( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/**/*.kt", ]), - assets = glob([ - "src/main/assets/assert-file.png", - ]), - assets_dir = "src/main/assets", build_config = { "strings": { "SOME_STRING": "Something", @@ -71,12 +67,18 @@ android_binary( "vi", "zh", ], - resources = { - "src/main/res-debug": { + resource_sets = { + "debug": { + "res": "src/main/res-debug", + "manifest": "src/debug/AndroidManifest.xml", }, - "src/free/res": { + "free": { + "res": "src/free/res", }, - "src/main/res": { + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [ @@ -114,10 +116,6 @@ android_binary( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/**/*.kt", ]), - assets = glob([ - "src/main/assets/assert-file.png", - ]), - assets_dir = "src/main/assets", build_config = { "strings": { "SOME_STRING": "Something", @@ -178,12 +176,18 @@ android_binary( "vi", "zh", ], - resources = { - "src/main/res-debug": { + resource_sets = { + "debug": { + "res": "src/main/res-debug", + "manifest": "src/debug/AndroidManifest.xml", }, - "src/paid/res": { + "paid": { + "res": "src/paid/res", }, - "src/main/res": { + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [ @@ -221,10 +225,6 @@ android_binary( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/**/*.kt", ]), - assets = glob([ - "src/main/assets/assert-file.png", - ]), - assets_dir = "src/main/assets", build_config = { "strings": { "SOME_STRING": "Something", @@ -285,12 +285,18 @@ android_binary( "vi", "zh", ], - resources = { - "src/main/res-debug": { + resource_sets = { + "debug": { + "res": "src/main/res-debug", + "manifest": "src/debug/AndroidManifest.xml", }, - "src/free/res": { + "free": { + "res": "src/free/res", }, - "src/main/res": { + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [ @@ -328,10 +334,6 @@ android_binary( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/**/*.kt", ]), - assets = glob([ - "src/main/assets/assert-file.png", - ]), - assets_dir = "src/main/assets", build_config = { "strings": { "SOME_STRING": "Something", @@ -392,12 +394,18 @@ android_binary( "vi", "zh", ], - resources = { - "src/main/res-debug": { - }, - "src/paid/res": { - }, - "src/main/res": { + resource_sets = { + "debug": { + "res": "src/main/res-debug", + "manifest": "src/debug/AndroidManifest.xml", + }, + "paid": { + "res": "src/paid/res", + }, + "main": { + "res": "src/main/res", + "assets": "src/main/assets", + "manifest": "src/main/AndroidManifest.xml", }, }, visibility = [