diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ComposeResourcesGeneration.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ComposeResourcesGeneration.kt index 33cf4fa8ce..672a479d0d 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ComposeResourcesGeneration.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ComposeResourcesGeneration.kt @@ -6,8 +6,14 @@ import org.jetbrains.compose.ComposePlugin import org.jetbrains.compose.internal.IDEA_IMPORT_TASK_NAME import org.jetbrains.compose.internal.IdeaImportTask import org.jetbrains.compose.internal.utils.uppercaseFirstChar +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension +import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget +import org.jetbrains.kotlin.tooling.core.withClosure import java.io.File internal fun Project.configureComposeResourcesGeneration( @@ -67,6 +73,8 @@ internal fun Project.configureComposeResourcesGeneration( ) } + configureResourceCollectorsGeneration(kotlinExtension, shouldGenerateCode, packageName, makeAccessorsPublic) + //setup task execution during IDE import tasks.configureEach { importTask -> if (importTask.name == IDEA_IMPORT_TASK_NAME) { @@ -115,7 +123,7 @@ private fun Project.configureResourceAccessorsGeneration( logger.info("Configure resource accessors generation for ${sourceSet.name}") val genTask = tasks.register( - "generateResourceAccessorsFor${sourceSet.name.uppercaseFirstChar()}", + sourceSet.getResourceAccessorsGenerationTaskName(), GenerateResourceAccessorsTask::class.java ) { task -> task.packageName.set(packageName) @@ -130,6 +138,132 @@ private fun Project.configureResourceAccessorsGeneration( } } + //register generated source set + sourceSet.kotlin.srcDir(genTask.map { it.codeDir }) +} + +private fun KotlinSourceSet.getResourceAccessorsGenerationTaskName(): String { + return "generateResourceAccessorsFor${this.name.uppercaseFirstChar()}" +} + +//we have to generate actual resource collector functions for each leaf source set +private fun Project.configureResourceCollectorsGeneration( + kotlinExtension: KotlinProjectExtension, + shouldGenerateCode: Provider, + packageName: Provider, + makeAccessorsPublic: Provider +) { + if (kotlinExtension is KotlinMultiplatformExtension) { + kotlinExtension.sourceSets + .matching { it.name == KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME } + .all { commonMainSourceSet -> + configureExpectResourceCollectorsGeneration( + commonMainSourceSet, + shouldGenerateCode, + packageName, + makeAccessorsPublic + ) + } + + kotlinExtension.targets.all { target -> + if (target is KotlinAndroidTarget) { + kotlinExtension.sourceSets.matching { it.name == "androidMain" }.all { androidMain -> + configureActualResourceCollectorsGeneration( + androidMain, + shouldGenerateCode, + packageName, + makeAccessorsPublic, + true + ) + } + } else if (target !is KotlinMetadataTarget) { + target.compilations.matching { it.name == KotlinCompilation.MAIN_COMPILATION_NAME }.all { compilation -> + configureActualResourceCollectorsGeneration( + compilation.defaultSourceSet, + shouldGenerateCode, + packageName, + makeAccessorsPublic, + true + ) + } + } + } + } else if (kotlinExtension is KotlinSingleTargetExtension<*>) { + //JVM only projects + kotlinExtension.target.compilations + .findByName(KotlinCompilation.MAIN_COMPILATION_NAME) + ?.let { compilation -> + configureActualResourceCollectorsGeneration( + compilation.defaultSourceSet, + shouldGenerateCode, + packageName, + makeAccessorsPublic, + false + ) + } + } + +} + +private fun Project.configureExpectResourceCollectorsGeneration( + sourceSet: KotlinSourceSet, + shouldGenerateCode: Provider, + packageName: Provider, + makeAccessorsPublic: Provider +) { + logger.info("Configure expect resource collectors generation for ${sourceSet.name}") + + + val genTask = tasks.register( + "generateExpectResourceCollectorsFor${sourceSet.name.uppercaseFirstChar()}", + GenerateExpectResourceCollectorsTask::class.java + ) { task -> + task.packageName.set(packageName) + task.shouldGenerateCode.set(shouldGenerateCode) + task.makeAccessorsPublic.set(makeAccessorsPublic) + task.codeDir.set(layout.buildDirectory.dir("$RES_GEN_DIR/kotlin/${sourceSet.name}ResourceCollectors")) + } + + //register generated source set + sourceSet.kotlin.srcDir(genTask.map { it.codeDir }) +} + +private fun Project.configureActualResourceCollectorsGeneration( + sourceSet: KotlinSourceSet, + shouldGenerateCode: Provider, + packageName: Provider, + makeAccessorsPublic: Provider, + useActualModifier: Boolean +) { + val taskName = "generateActualResourceCollectorsFor${sourceSet.name.uppercaseFirstChar()}" + if (tasks.names.contains(taskName)) { + logger.info("Actual resource collectors generation for ${sourceSet.name} is already configured") + return + } + logger.info("Configure actual resource collectors generation for ${sourceSet.name}") + + val accessorDirs = project.files({ + val allSourceSets = sourceSet.withClosure { it.dependsOn } + allSourceSets.mapNotNull { item -> + val accessorsTaskName = item.getResourceAccessorsGenerationTaskName() + if (tasks.names.contains(accessorsTaskName)) { + tasks.named(accessorsTaskName, GenerateResourceAccessorsTask::class.java).map { it.codeDir } + } else null + } + }) + + val genTask = tasks.register( + taskName, + GenerateActualResourceCollectorsTask::class.java + ) { task -> + task.packageName.set(packageName) + task.shouldGenerateCode.set(shouldGenerateCode) + task.makeAccessorsPublic.set(makeAccessorsPublic) + task.useActualModifier.set(useActualModifier) + task.resourceAccessorDirs.from(accessorDirs) + task.codeDir.set(layout.buildDirectory.dir("$RES_GEN_DIR/kotlin/${sourceSet.name}ResourceCollectors")) + } + //register generated source set sourceSet.kotlin.srcDir(genTask.map { it.codeDir }) } \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GenerateResourceCollectorsTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GenerateResourceCollectorsTask.kt new file mode 100644 index 0000000000..bd67c804f5 --- /dev/null +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GenerateResourceCollectorsTask.kt @@ -0,0 +1,116 @@ +package org.jetbrains.compose.resources + +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.jetbrains.compose.internal.IdeaImportTask +import org.jetbrains.compose.internal.utils.uppercaseFirstChar + +internal abstract class GenerateExpectResourceCollectorsTask : IdeaImportTask() { + @get:Input + abstract val packageName: Property + + @get:Input + abstract val shouldGenerateCode: Property + + @get:Input + abstract val makeAccessorsPublic: Property + + @get:OutputDirectory + abstract val codeDir: DirectoryProperty + + override fun safeAction() { + val kotlinDir = codeDir.get().asFile + + logger.info("Clean directory $kotlinDir") + kotlinDir.deleteRecursively() + kotlinDir.mkdirs() + + if (shouldGenerateCode.get()) { + logger.info("Generate expect ResourceCollectors for $kotlinDir") + + val pkgName = packageName.get() + val isPublic = makeAccessorsPublic.get() + val spec = getExpectResourceCollectorsFileSpec(pkgName, "ExpectResourceCollectors", isPublic) + spec.writeTo(kotlinDir) + } + } +} + +internal abstract class GenerateActualResourceCollectorsTask : IdeaImportTask() { + @get:Input + abstract val packageName: Property + + @get:Input + abstract val shouldGenerateCode: Property + + @get:Input + abstract val makeAccessorsPublic: Property + + @get:Input + abstract val useActualModifier: Property + + @get:InputFiles + @get:PathSensitive(PathSensitivity.RELATIVE) + abstract val resourceAccessorDirs: ConfigurableFileCollection + + @get:OutputDirectory + abstract val codeDir: DirectoryProperty + + override fun safeAction() { + val kotlinDir = codeDir.get().asFile + val inputDirs = resourceAccessorDirs.files + + logger.info("Clean directory $kotlinDir") + kotlinDir.deleteRecursively() + kotlinDir.mkdirs() + + val inputFiles = inputDirs.flatMap { dir -> + dir.walkTopDown().filter { !it.isHidden && it.isFile && it.extension == "kt" }.toList() + } + + if (shouldGenerateCode.get()) { + logger.info("Generate actual ResourceCollectors for $kotlinDir") + val funNames = inputFiles.mapNotNull { inputFile -> + if (inputFile.nameWithoutExtension.contains('.')) { + val (fileName, suffix) = inputFile.nameWithoutExtension.split('.') + val type = ResourceType.values().firstOrNull { fileName.startsWith(it.accessorName, true) } + val name = "_collect${suffix.uppercaseFirstChar()}${fileName}Resources" + + if (type == null) { + logger.warn("Unknown resources type: `$inputFile`") + null + } else if (!inputFile.readText().contains(name)) { + logger.warn("A function '$name' is not found in the `$inputFile` file!") + null + } else { + logger.info("Found collector function: `$name`") + type to name + } + } else { + logger.warn("Unknown file name: `$inputFile`") + null + } + }.groupBy({ it.first }, { it.second }) + + val pkgName = packageName.get() + val isPublic = makeAccessorsPublic.get() + val useActual = useActualModifier.get() + val spec = getActualResourceCollectorsFileSpec( + pkgName, + "ActualResourceCollectors", + isPublic, + useActual, + funNames + ) + spec.writeTo(kotlinDir) + } else { + logger.info("Generation ResourceCollectors for $kotlinDir is disabled") + } + } +} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt index df8add1101..559f0471b3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt @@ -1,6 +1,19 @@ package org.jetbrains.compose.resources -import com.squareup.kotlinpoet.* +import com.squareup.kotlinpoet.AnnotationSpec +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.CodeBlock +import com.squareup.kotlinpoet.FileSpec +import com.squareup.kotlinpoet.FunSpec +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.MAP +import com.squareup.kotlinpoet.MUTABLE_MAP +import com.squareup.kotlinpoet.MemberName +import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy +import com.squareup.kotlinpoet.PropertySpec +import com.squareup.kotlinpoet.TypeSpec +import com.squareup.kotlinpoet.asClassName +import com.squareup.kotlinpoet.withIndent import org.jetbrains.compose.internal.utils.uppercaseFirstChar import java.nio.file.Path import java.util.* @@ -45,6 +58,9 @@ private val resourceItemClass = ClassName("org.jetbrains.compose.resources", "Re private val experimentalAnnotation = AnnotationSpec.builder( ClassName("org.jetbrains.compose.resources", "ExperimentalResourceApi") ).build() +private val internalAnnotation = AnnotationSpec.builder( + ClassName("org.jetbrains.compose.resources", "InternalResourceApi") +).build() private fun CodeBlock.Builder.addQualifiers(resourceItem: ResourceItem): CodeBlock.Builder { val languageQualifier = ClassName("org.jetbrains.compose.resources", "LanguageQualifier") @@ -247,6 +263,23 @@ private fun getChunkFileSpec( }.build() chunkFile.addType(objectSpec) + //__collect${chunkClassName}Resources function + chunkFile.addFunction( + FunSpec.builder("_collect${chunkClassName}Resources") + .addAnnotation(internalAnnotation) + .addModifiers(KModifier.INTERNAL) + .addParameter( + "map", + MUTABLE_MAP.parameterizedBy(String::class.asClassName(), type.getClassName()) + ) + .also { collectFun -> + idToResources.keys.forEach { resName -> + collectFun.addStatement("map.put(%S, $chunkClassName.%N)", resName, resName) + } + } + .build() + ) + idToResources.forEach { (resName, items) -> val accessor = PropertySpec.builder(resName, type.getClassName(), resModifier) .receiver(ClassName(packageName, "Res", type.accessorName)) @@ -285,6 +318,79 @@ private fun getChunkFileSpec( }.build() } +internal fun getExpectResourceCollectorsFileSpec( + packageName: String, + fileName: String, + isPublic: Boolean +): FileSpec { + val resModifier = if (isPublic) KModifier.PUBLIC else KModifier.INTERNAL + return FileSpec.builder(packageName, fileName).also { file -> + ResourceType.values().forEach { type -> + val typeClassName = type.getClassName() + file.addProperty( + PropertySpec + .builder( + "all${typeClassName.simpleName}s", + MAP.parameterizedBy(String::class.asClassName(), typeClassName), + KModifier.EXPECT, + resModifier + ) + .addAnnotation(experimentalAnnotation) + .receiver(ClassName(packageName, "Res")) + .build() + ) + } + }.build() +} + +internal fun getActualResourceCollectorsFileSpec( + packageName: String, + fileName: String, + isPublic: Boolean, + useActualModifier: Boolean, //e.g. java only project doesn't need actual modifiers + typeToCollectorFunctions: Map> +): FileSpec = FileSpec.builder(packageName, fileName).also { file -> + val resModifier = if (isPublic) KModifier.PUBLIC else KModifier.INTERNAL + + file.addAnnotation( + AnnotationSpec.builder(ClassName("kotlin", "OptIn")) + .addMember("org.jetbrains.compose.resources.InternalResourceApi::class") + .build() + ) + + ResourceType.values().forEach { type -> + val typeClassName = type.getClassName() + val initBlock = CodeBlock.builder() + .addStatement("lazy {").withIndent { + addStatement("val map = mutableMapOf()", typeClassName) + typeToCollectorFunctions.get(type).orEmpty().forEach { item -> + addStatement("%N(map)", item) + } + addStatement("return@lazy map") + } + .addStatement("}") + .build() + + val mods = if (useActualModifier) { + listOf(KModifier.ACTUAL, resModifier) + } else { + listOf(resModifier) + } + + val property = PropertySpec + .builder( + "all${typeClassName.simpleName}s", + MAP.parameterizedBy(String::class.asClassName(), typeClassName), + mods + ) + .addAnnotation(experimentalAnnotation) + .receiver(ClassName(packageName, "Res")) + .delegate(initBlock) + .build() + file.addProperty(property) + } +}.build() + private fun sortResources( resources: Map>> ): TreeMap>> { diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt index 5ef8f5f393..0aeb94a2d8 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt @@ -513,9 +513,9 @@ class ResourcesTest : GradlePluginTestBase() { @Test fun testEmptyResClass(): Unit = with(testProject("misc/emptyResources")) { - gradle("generateComposeResClass").checks { + gradle("prepareKotlinIdeaImport").checks { assertDirectoriesContentEquals( - file("build/generated/compose/resourceGenerator/kotlin/commonResClass/app/group/empty_res/generated/resources"), + file("build/generated/compose/resourceGenerator/kotlin"), file("expected") ) } diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt index 5d0d9e00b0..9d1d0e7a42 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt @@ -3,20 +3,28 @@ package my.lib.res import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.StringResource private object AndroidMainString0 { - public val android_str: StringResource by - lazy { init_android_str() } + public val android_str: StringResource by + lazy { init_android_str() } +} + +@InternalResourceApi +internal fun _collectAndroidMainString0Resources(map: MutableMap) { + map.put("android_str", AndroidMainString0.android_str) } public val Res.string.android_str: StringResource - get() = AndroidMainString0.android_str + get() = AndroidMainString0.android_str private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:android_str", "android_str", + "string:android_str", "android_str", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.androidMain.cvr", 10, 39), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.androidMain.cvr", 10, 39), ) -) \ No newline at end of file +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt new file mode 100644 index 0000000000..9f91d73840 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt @@ -0,0 +1,53 @@ +@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) + +package my.lib.res + +import kotlin.OptIn +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +public actual val Res.allDrawableResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainDrawable0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allStringResources: Map by lazy { + val map = mutableMapOf() + _collectAndroidMainString0Resources(map) + _collectCommonMainString0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allStringArrayResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allPluralStringResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainPlurals0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allFontResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainFont0Resources(map) + return@lazy map +} + diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt index fc67e497cb..060e66ad48 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt @@ -3,58 +3,70 @@ package my.lib.res import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.InternalResourceApi private object CommonMainDrawable0 { - public val _3_strange_name: DrawableResource by - lazy { init__3_strange_name() } + public val _3_strange_name: DrawableResource by + lazy { init__3_strange_name() } - public val camelCaseName: DrawableResource by - lazy { init_camelCaseName() } + public val camelCaseName: DrawableResource by + lazy { init_camelCaseName() } - public val `is`: DrawableResource by - lazy { init_is() } + public val `is`: DrawableResource by + lazy { init_is() } - public val vector: DrawableResource by - lazy { init_vector() } + public val vector: DrawableResource by + lazy { init_vector() } - public val vector_2: DrawableResource by - lazy { init_vector_2() } + public val vector_2: DrawableResource by + lazy { init_vector_2() } +} + +@InternalResourceApi +internal fun _collectCommonMainDrawable0Resources(map: MutableMap) { + map.put("_3_strange_name", CommonMainDrawable0._3_strange_name) + map.put("camelCaseName", CommonMainDrawable0.camelCaseName) + map.put("is", CommonMainDrawable0.`is`) + map.put("vector", CommonMainDrawable0.vector) + map.put("vector_2", CommonMainDrawable0.vector_2) } public val Res.drawable._3_strange_name: DrawableResource get() = CommonMainDrawable0._3_strange_name private fun init__3_strange_name(): DrawableResource = - org.jetbrains.compose.resources.DrawableResource( - "drawable:_3_strange_name", + org.jetbrains.compose.resources.DrawableResource( + "drawable:_3_strange_name", setOf( org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/drawable/3-strange-name.xml", -1, -1), + "composeResources/my.lib.res/drawable/3-strange-name.xml", -1, -1), ) - ) +) public val Res.drawable.camelCaseName: DrawableResource get() = CommonMainDrawable0.camelCaseName private fun init_camelCaseName(): DrawableResource = - org.jetbrains.compose.resources.DrawableResource( - "drawable:camelCaseName", + org.jetbrains.compose.resources.DrawableResource( + "drawable:camelCaseName", setOf( org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/drawable/camelCaseName.xml", -1, -1), + "composeResources/my.lib.res/drawable/camelCaseName.xml", -1, -1), ) - ) +) public val Res.drawable.`is`: DrawableResource get() = CommonMainDrawable0.`is` private fun init_is(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:is", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/drawable/is.xml", -1, -1), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/drawable/is.xml", -1, -1), + ) ) public val Res.drawable.vector: DrawableResource @@ -62,24 +74,24 @@ public val Res.drawable.vector: DrawableResource private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector", - setOf( - + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("ast"), ), "composeResources/my.lib.res/drawable-ast/vector.xml", -1, -1), - + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("au"), - org.jetbrains.compose.resources.RegionQualifier("US"), ), - "composeResources/my.lib.res/drawable-au-rUS/vector.xml", -1, -1), - + org.jetbrains.compose.resources.RegionQualifier("US"), ), + "composeResources/my.lib.res/drawable-au-rUS/vector.xml", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.ThemeQualifier.DARK, - org.jetbrains.compose.resources.LanguageQualifier("ge"), ), - "composeResources/my.lib.res/drawable-dark-ge/vector.xml", -1, -1), - + org.jetbrains.compose.resources.LanguageQualifier("ge"), ), + "composeResources/my.lib.res/drawable-dark-ge/vector.xml", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"), ), "composeResources/my.lib.res/drawable-en/vector.xml", -1, -1), - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/drawable/vector.xml", -1, -1), - ) + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/drawable/vector.xml", -1, -1), + ) ) public val Res.drawable.vector_2: DrawableResource @@ -87,8 +99,8 @@ public val Res.drawable.vector_2: DrawableResource private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector_2", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/drawable/vector_2.xml", -1, -1), - ) -) \ No newline at end of file + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/drawable/vector_2.xml", -1, -1), + ) +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt index c754abef21..f6e1193540 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt @@ -3,11 +3,19 @@ package my.lib.res import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.InternalResourceApi private object CommonMainFont0 { - public val emptyFont: FontResource by - lazy { init_emptyFont() } + public val emptyFont: FontResource by + lazy { init_emptyFont() } +} + +@InternalResourceApi +internal fun _collectCommonMainFont0Resources(map: MutableMap) { + map.put("emptyFont", CommonMainFont0.emptyFont) } public val Res.font.emptyFont: FontResource @@ -15,11 +23,11 @@ public val Res.font.emptyFont: FontResource private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource( "font:emptyFont", - setOf( - + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"), ), "composeResources/my.lib.res/font-en/emptyFont.otf", -1, -1), - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/font/emptyFont.otf", -1, -1), - ) -) \ No newline at end of file + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/font/emptyFont.otf", -1, -1), + ) +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt index e97fd6730d..7a397b4235 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt @@ -3,21 +3,29 @@ package my.lib.res import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.PluralStringResource private object CommonMainPlurals0 { - public val numberOfSongsAvailable: PluralStringResource by - lazy { init_numberOfSongsAvailable() } + public val numberOfSongsAvailable: PluralStringResource by + lazy { init_numberOfSongsAvailable() } +} + +@InternalResourceApi +internal fun _collectCommonMainPlurals0Resources(map: MutableMap) { + map.put("numberOfSongsAvailable", CommonMainPlurals0.numberOfSongsAvailable) } public val Res.plurals.numberOfSongsAvailable: PluralStringResource - get() = CommonMainPlurals0.numberOfSongsAvailable + get() = CommonMainPlurals0.numberOfSongsAvailable private fun init_numberOfSongsAvailable(): PluralStringResource = org.jetbrains.compose.resources.PluralStringResource( - "plurals:numberOfSongsAvailable", "numberOfSongsAvailable", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 10, 124), - ) - ) \ No newline at end of file + "plurals:numberOfSongsAvailable", "numberOfSongsAvailable", + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 10, 124), + ) +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt index 401c58853a..49fa3f8a39 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt @@ -3,32 +3,47 @@ package my.lib.res import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.StringResource private object CommonMainString0 { - public val PascalCase: StringResource by - lazy { init_PascalCase() } + public val PascalCase: StringResource by + lazy { init_PascalCase() } - public val _1_kebab_case: StringResource by - lazy { init__1_kebab_case() } + public val _1_kebab_case: StringResource by + lazy { init__1_kebab_case() } - public val app_name: StringResource by - lazy { init_app_name() } + public val app_name: StringResource by + lazy { init_app_name() } - public val camelCase: StringResource by - lazy { init_camelCase() } + public val camelCase: StringResource by + lazy { init_camelCase() } - public val hello: StringResource by - lazy { init_hello() } + public val hello: StringResource by + lazy { init_hello() } - public val `info_using_release_$x`: StringResource by - lazy { `init_info_using_release_$x`() } + public val `info_using_release_$x`: StringResource by + lazy { `init_info_using_release_$x`() } - public val multi_line: StringResource by - lazy { init_multi_line() } + public val multi_line: StringResource by + lazy { init_multi_line() } - public val str_template: StringResource by - lazy { init_str_template() } + public val str_template: StringResource by + lazy { init_str_template() } +} + +@InternalResourceApi +internal fun _collectCommonMainString0Resources(map: MutableMap) { + map.put("PascalCase", CommonMainString0.PascalCase) + map.put("_1_kebab_case", CommonMainString0._1_kebab_case) + map.put("app_name", CommonMainString0.app_name) + map.put("camelCase", CommonMainString0.camelCase) + map.put("hello", CommonMainString0.hello) + map.put("info_using_release_${'$'}x", CommonMainString0.`info_using_release_$x`) + map.put("multi_line", CommonMainString0.multi_line) + map.put("str_template", CommonMainString0.str_template) } public val Res.string.PascalCase: StringResource @@ -36,10 +51,10 @@ public val Res.string.PascalCase: StringResource private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource( "string:PascalCase", "PascalCase", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 172, 34), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 172, 34), + ) ) public val Res.string._1_kebab_case: StringResource @@ -47,10 +62,10 @@ public val Res.string._1_kebab_case: StringResource private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource( "string:_1_kebab_case", "_1_kebab_case", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 135, 36), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 135, 36), + ) ) public val Res.string.app_name: StringResource @@ -58,10 +73,10 @@ public val Res.string.app_name: StringResource private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource( "string:app_name", "app_name", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 207, 44), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 207, 44), + ) ) public val Res.string.camelCase: StringResource @@ -69,10 +84,10 @@ public val Res.string.camelCase: StringResource private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource( "string:camelCase", "camelCase", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 252, 29), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 252, 29), + ) ) public val Res.string.hello: StringResource @@ -80,33 +95,33 @@ public val Res.string.hello: StringResource private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource( "string:hello", "hello", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 282, 37), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 282, 37), + ) ) public val Res.string.`info_using_release_$x`: StringResource get() = CommonMainString0.`info_using_release_$x` private fun `init_info_using_release_$x`(): StringResource = - org.jetbrains.compose.resources.StringResource( - "string:info_using_release_${'$'}x", "info_using_release_${'$'}x", + org.jetbrains.compose.resources.StringResource( + "string:info_using_release_${'$'}x", "info_using_release_${'$'}x", setOf( org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 320, 57), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 320, 57), ) - ) +) public val Res.string.multi_line: StringResource get() = CommonMainString0.multi_line private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource( "string:multi_line", "multi_line", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 378, 178), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 378, 178), + ) ) public val Res.string.str_template: StringResource @@ -114,8 +129,8 @@ public val Res.string.str_template: StringResource private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource( "string:str_template", "str_template", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/strings.commonMain.cvr", 557, 76), - ) -) \ No newline at end of file + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/strings.commonMain.cvr", 557, 76), + ) +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceCollectors/my/lib/res/ExpectResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceCollectors/my/lib/res/ExpectResourceCollectors.kt new file mode 100644 index 0000000000..6ea528da50 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceCollectors/my/lib/res/ExpectResourceCollectors.kt @@ -0,0 +1,25 @@ +package my.lib.res + +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +public expect val Res.allDrawableResources: Map + +@ExperimentalResourceApi +public expect val Res.allStringResources: Map + +@ExperimentalResourceApi +public expect val Res.allStringArrayResources: Map + +@ExperimentalResourceApi +public expect val Res.allPluralStringResources: Map + +@ExperimentalResourceApi +public expect val Res.allFontResources: Map diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt index 50ce381bf1..1cfbcd76e6 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt @@ -23,7 +23,7 @@ public object Res { */ @ExperimentalResourceApi public suspend fun readBytes(path: String): ByteArray = - readResourceBytes("composeResources/my.lib.res/" + path) + readResourceBytes("composeResources/my.lib.res/" + path) /** * Returns the URI string of the resource file at the specified path. @@ -45,4 +45,4 @@ public object Res { public object plurals public object font -} \ No newline at end of file +} diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt index d002471d46..f3e28a5b40 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt @@ -3,20 +3,28 @@ package my.lib.res import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.StringResource private object DesktopMainString0 { - public val desktop_str: StringResource by - lazy { init_desktop_str() } + public val desktop_str: StringResource by + lazy { init_desktop_str() } +} + +@InternalResourceApi +internal fun _collectDesktopMainString0Resources(map: MutableMap) { + map.put("desktop_str", DesktopMainString0.desktop_str) } public val Res.string.desktop_str: StringResource - get() = DesktopMainString0.desktop_str + get() = DesktopMainString0.desktop_str private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:desktop_str", "desktop_str", + "string:desktop_str", "desktop_str", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/my.lib.res/values/desktop_strings.desktopMain.cvr", 10, 39), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/my.lib.res/values/desktop_strings.desktopMain.cvr", 10, 39), ) -) \ No newline at end of file +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt new file mode 100644 index 0000000000..5b8690a54a --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt @@ -0,0 +1,53 @@ +@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) + +package my.lib.res + +import kotlin.OptIn +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +public actual val Res.allDrawableResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainDrawable0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allStringResources: Map by lazy { + val map = mutableMapOf() + _collectDesktopMainString0Resources(map) + _collectCommonMainString0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allStringArrayResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allPluralStringResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainPlurals0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +public actual val Res.allFontResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainFont0Resources(map) + return@lazy map +} + diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt index 0b672fbfde..020c0d9dce 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt @@ -3,21 +3,29 @@ package app.group.resources_test.generated.resources import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.StringResource private object AndroidMainString0 { - public val android_str: StringResource by - lazy { init_android_str() } + public val android_str: StringResource by + lazy { init_android_str() } +} + +@InternalResourceApi +internal fun _collectAndroidMainString0Resources(map: MutableMap) { + map.put("android_str", AndroidMainString0.android_str) } internal val Res.string.android_str: StringResource - get() = AndroidMainString0.android_str + get() = AndroidMainString0.android_str private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:android_str", "android_str", + "string:android_str", "android_str", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.androidMain.cvr", - 10, 39), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.androidMain.cvr", + 10, 39), ) -) \ No newline at end of file +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt new file mode 100644 index 0000000000..b747b87218 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt @@ -0,0 +1,53 @@ +@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) + +package app.group.resources_test.generated.resources + +import kotlin.OptIn +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +internal actual val Res.allDrawableResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainDrawable0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allStringResources: Map by lazy { + val map = mutableMapOf() + _collectAndroidMainString0Resources(map) + _collectCommonMainString0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allStringArrayResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allPluralStringResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainPlurals0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allFontResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainFont0Resources(map) + return@lazy map +} + diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt index d4b0e2aa25..b648204784 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt @@ -3,58 +3,70 @@ package app.group.resources_test.generated.resources import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.InternalResourceApi private object CommonMainDrawable0 { - public val _3_strange_name: DrawableResource by - lazy { init__3_strange_name() } + public val _3_strange_name: DrawableResource by + lazy { init__3_strange_name() } - public val camelCaseName: DrawableResource by - lazy { init_camelCaseName() } + public val camelCaseName: DrawableResource by + lazy { init_camelCaseName() } - public val `is`: DrawableResource by - lazy { init_is() } + public val `is`: DrawableResource by + lazy { init_is() } - public val vector: DrawableResource by - lazy { init_vector() } + public val vector: DrawableResource by + lazy { init_vector() } - public val vector_2: DrawableResource by - lazy { init_vector_2() } + public val vector_2: DrawableResource by + lazy { init_vector_2() } +} + +@InternalResourceApi +internal fun _collectCommonMainDrawable0Resources(map: MutableMap) { + map.put("_3_strange_name", CommonMainDrawable0._3_strange_name) + map.put("camelCaseName", CommonMainDrawable0.camelCaseName) + map.put("is", CommonMainDrawable0.`is`) + map.put("vector", CommonMainDrawable0.vector) + map.put("vector_2", CommonMainDrawable0.vector_2) } internal val Res.drawable._3_strange_name: DrawableResource get() = CommonMainDrawable0._3_strange_name private fun init__3_strange_name(): DrawableResource = - org.jetbrains.compose.resources.DrawableResource( - "drawable:_3_strange_name", + org.jetbrains.compose.resources.DrawableResource( + "drawable:_3_strange_name", setOf( org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/drawable/3-strange-name.xml", -1, -1), + "composeResources/app.group.resources_test.generated.resources/drawable/3-strange-name.xml", -1, -1), ) - ) +) internal val Res.drawable.camelCaseName: DrawableResource get() = CommonMainDrawable0.camelCaseName private fun init_camelCaseName(): DrawableResource = - org.jetbrains.compose.resources.DrawableResource( - "drawable:camelCaseName", + org.jetbrains.compose.resources.DrawableResource( + "drawable:camelCaseName", setOf( org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/drawable/camelCaseName.xml", -1, -1), + "composeResources/app.group.resources_test.generated.resources/drawable/camelCaseName.xml", -1, -1), ) - ) +) internal val Res.drawable.`is`: DrawableResource get() = CommonMainDrawable0.`is` private fun init_is(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:is", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/drawable/is.xml", -1, -1), - ) + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/drawable/is.xml", -1, -1), + ) ) internal val Res.drawable.vector: DrawableResource @@ -62,26 +74,26 @@ internal val Res.drawable.vector: DrawableResource private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector", - setOf( - + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("ast"), ), - "composeResources/app.group.resources_test.generated.resources/drawable-ast/vector.xml", -1, -1), - + "composeResources/app.group.resources_test.generated.resources/drawable-ast/vector.xml", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("au"), - org.jetbrains.compose.resources.RegionQualifier("US"), ), - "composeResources/app.group.resources_test.generated.resources/drawable-au-rUS/vector.xml", -1, -1), - + org.jetbrains.compose.resources.RegionQualifier("US"), ), + "composeResources/app.group.resources_test.generated.resources/drawable-au-rUS/vector.xml", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.ThemeQualifier.DARK, - org.jetbrains.compose.resources.LanguageQualifier("ge"), ), - "composeResources/app.group.resources_test.generated.resources/drawable-dark-ge/vector.xml", -1, -1), - + org.jetbrains.compose.resources.LanguageQualifier("ge"), ), + "composeResources/app.group.resources_test.generated.resources/drawable-dark-ge/vector.xml", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"), ), - "composeResources/app.group.resources_test.generated.resources/drawable-en/vector.xml", -1, -1), - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/drawable/vector.xml", -1, -1), - ) + "composeResources/app.group.resources_test.generated.resources/drawable-en/vector.xml", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/drawable/vector.xml", -1, -1), + ) ) internal val Res.drawable.vector_2: DrawableResource @@ -89,8 +101,8 @@ internal val Res.drawable.vector_2: DrawableResource private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( "drawable:vector_2", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/drawable/vector_2.xml", -1, -1), - ) -) \ No newline at end of file + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/drawable/vector_2.xml", -1, -1), + ) +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt index 432d74d5f6..6f89aaafa0 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt @@ -3,11 +3,19 @@ package app.group.resources_test.generated.resources import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.InternalResourceApi private object CommonMainFont0 { - public val emptyFont: FontResource by - lazy { init_emptyFont() } + public val emptyFont: FontResource by + lazy { init_emptyFont() } +} + +@InternalResourceApi +internal fun _collectCommonMainFont0Resources(map: MutableMap) { + map.put("emptyFont", CommonMainFont0.emptyFont) } internal val Res.font.emptyFont: FontResource @@ -15,12 +23,12 @@ internal val Res.font.emptyFont: FontResource private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource( "font:emptyFont", - setOf( - + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"), ), - "composeResources/app.group.resources_test.generated.resources/font-en/emptyFont.otf", -1, -1), - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/font/emptyFont.otf", -1, -1), - ) -) \ No newline at end of file + "composeResources/app.group.resources_test.generated.resources/font-en/emptyFont.otf", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/font/emptyFont.otf", -1, -1), + ) +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt index b6b1abf697..c4c172ec20 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt @@ -3,22 +3,30 @@ package app.group.resources_test.generated.resources import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.PluralStringResource private object CommonMainPlurals0 { - public val numberOfSongsAvailable: PluralStringResource by - lazy { init_numberOfSongsAvailable() } + public val numberOfSongsAvailable: PluralStringResource by + lazy { init_numberOfSongsAvailable() } +} + +@InternalResourceApi +internal fun _collectCommonMainPlurals0Resources(map: MutableMap) { + map.put("numberOfSongsAvailable", CommonMainPlurals0.numberOfSongsAvailable) } internal val Res.plurals.numberOfSongsAvailable: PluralStringResource - get() = CommonMainPlurals0.numberOfSongsAvailable + get() = CommonMainPlurals0.numberOfSongsAvailable private fun init_numberOfSongsAvailable(): PluralStringResource = org.jetbrains.compose.resources.PluralStringResource( - "plurals:numberOfSongsAvailable", "numberOfSongsAvailable", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 10, 124), - ) - ) \ No newline at end of file + "plurals:numberOfSongsAvailable", "numberOfSongsAvailable", + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 10, 124), + ) +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt index 9576f03c4f..50ab7a156f 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt @@ -3,127 +3,142 @@ package app.group.resources_test.generated.resources import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.StringResource private object CommonMainString0 { - public val PascalCase: StringResource by - lazy { init_PascalCase() } + public val PascalCase: StringResource by + lazy { init_PascalCase() } - public val _1_kebab_case: StringResource by - lazy { init__1_kebab_case() } + public val _1_kebab_case: StringResource by + lazy { init__1_kebab_case() } - public val app_name: StringResource by - lazy { init_app_name() } + public val app_name: StringResource by + lazy { init_app_name() } - public val camelCase: StringResource by - lazy { init_camelCase() } + public val camelCase: StringResource by + lazy { init_camelCase() } - public val hello: StringResource by - lazy { init_hello() } + public val hello: StringResource by + lazy { init_hello() } - public val `info_using_release_$x`: StringResource by - lazy { `init_info_using_release_$x`() } + public val `info_using_release_$x`: StringResource by + lazy { `init_info_using_release_$x`() } - public val multi_line: StringResource by - lazy { init_multi_line() } + public val multi_line: StringResource by + lazy { init_multi_line() } - public val str_template: StringResource by - lazy { init_str_template() } + public val str_template: StringResource by + lazy { init_str_template() } +} + +@InternalResourceApi +internal fun _collectCommonMainString0Resources(map: MutableMap) { + map.put("PascalCase", CommonMainString0.PascalCase) + map.put("_1_kebab_case", CommonMainString0._1_kebab_case) + map.put("app_name", CommonMainString0.app_name) + map.put("camelCase", CommonMainString0.camelCase) + map.put("hello", CommonMainString0.hello) + map.put("info_using_release_${'$'}x", CommonMainString0.`info_using_release_$x`) + map.put("multi_line", CommonMainString0.multi_line) + map.put("str_template", CommonMainString0.str_template) } internal val Res.string.PascalCase: StringResource - get() = CommonMainString0.PascalCase + get() = CommonMainString0.PascalCase private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:PascalCase", "PascalCase", + "string:PascalCase", "PascalCase", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 172, 34), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 172, 34), ) ) internal val Res.string._1_kebab_case: StringResource - get() = CommonMainString0._1_kebab_case + get() = CommonMainString0._1_kebab_case private fun init__1_kebab_case(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:_1_kebab_case", "_1_kebab_case", + "string:_1_kebab_case", "_1_kebab_case", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 135, 36), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 135, 36), ) ) internal val Res.string.app_name: StringResource - get() = CommonMainString0.app_name + get() = CommonMainString0.app_name private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:app_name", "app_name", + "string:app_name", "app_name", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 207, 44), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 207, 44), ) ) internal val Res.string.camelCase: StringResource - get() = CommonMainString0.camelCase + get() = CommonMainString0.camelCase private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:camelCase", "camelCase", + "string:camelCase", "camelCase", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 252, 29), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 252, 29), ) ) internal val Res.string.hello: StringResource - get() = CommonMainString0.hello + get() = CommonMainString0.hello private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:hello", "hello", + "string:hello", "hello", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 282, 37), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 282, 37), ) ) internal val Res.string.`info_using_release_$x`: StringResource - get() = CommonMainString0.`info_using_release_$x` + get() = CommonMainString0.`info_using_release_$x` private fun `init_info_using_release_$x`(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:info_using_release_${'$'}x", "info_using_release_${'$'}x", - setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 320, 57), - ) + "string:info_using_release_${'$'}x", "info_using_release_${'$'}x", + setOf( + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 320, 57), ) +) internal val Res.string.multi_line: StringResource - get() = CommonMainString0.multi_line + get() = CommonMainString0.multi_line private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:multi_line", "multi_line", + "string:multi_line", "multi_line", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 378, 178), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 378, 178), ) ) internal val Res.string.str_template: StringResource - get() = CommonMainString0.str_template + get() = CommonMainString0.str_template private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:str_template", "str_template", + "string:str_template", "str_template", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", - 557, 76), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", + 557, 76), ) -) \ No newline at end of file +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceCollectors/app/group/resources_test/generated/resources/ExpectResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceCollectors/app/group/resources_test/generated/resources/ExpectResourceCollectors.kt new file mode 100644 index 0000000000..e287403867 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceCollectors/app/group/resources_test/generated/resources/ExpectResourceCollectors.kt @@ -0,0 +1,25 @@ +package app.group.resources_test.generated.resources + +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +internal expect val Res.allDrawableResources: Map + +@ExperimentalResourceApi +internal expect val Res.allStringResources: Map + +@ExperimentalResourceApi +internal expect val Res.allStringArrayResources: Map + +@ExperimentalResourceApi +internal expect val Res.allPluralStringResources: Map + +@ExperimentalResourceApi +internal expect val Res.allFontResources: Map diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt index 58b19ebe7a..73506c4d6d 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt @@ -23,7 +23,7 @@ internal object Res { */ @ExperimentalResourceApi public suspend fun readBytes(path: String): ByteArray = - readResourceBytes("composeResources/app.group.resources_test.generated.resources/" + path) + readResourceBytes("composeResources/app.group.resources_test.generated.resources/" + path) /** * Returns the URI string of the resource file at the specified path. @@ -35,7 +35,7 @@ internal object Res { */ @ExperimentalResourceApi public fun getUri(path: String): String = - getResourceUri("composeResources/app.group.resources_test.generated.resources/" + path) + getResourceUri("composeResources/app.group.resources_test.generated.resources/" + path) public object drawable @@ -46,4 +46,4 @@ internal object Res { public object plurals public object font -} \ No newline at end of file +} diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt index 0eabfd7621..2948107939 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt @@ -3,21 +3,29 @@ package app.group.resources_test.generated.resources import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap +import org.jetbrains.compose.resources.InternalResourceApi import org.jetbrains.compose.resources.StringResource private object DesktopMainString0 { - public val desktop_str: StringResource by - lazy { init_desktop_str() } + public val desktop_str: StringResource by + lazy { init_desktop_str() } +} + +@InternalResourceApi +internal fun _collectDesktopMainString0Resources(map: MutableMap) { + map.put("desktop_str", DesktopMainString0.desktop_str) } internal val Res.string.desktop_str: StringResource - get() = DesktopMainString0.desktop_str + get() = DesktopMainString0.desktop_str private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource( - "string:desktop_str", "desktop_str", + "string:desktop_str", "desktop_str", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), - "composeResources/app.group.resources_test.generated.resources/values/desktop_strings.desktopMain.cvr", - 10, 39), + org.jetbrains.compose.resources.ResourceItem(setOf(), + "composeResources/app.group.resources_test.generated.resources/values/desktop_strings.desktopMain.cvr", + 10, 39), ) -) \ No newline at end of file +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt new file mode 100644 index 0000000000..d349d941b4 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt @@ -0,0 +1,53 @@ +@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) + +package app.group.resources_test.generated.resources + +import kotlin.OptIn +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +internal actual val Res.allDrawableResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainDrawable0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allStringResources: Map by lazy { + val map = mutableMapOf() + _collectDesktopMainString0Resources(map) + _collectCommonMainString0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allStringArrayResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allPluralStringResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainPlurals0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allFontResources: Map by lazy { + val map = mutableMapOf() + _collectCommonMainFont0Resources(map) + return@lazy map +} + diff --git a/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt deleted file mode 100644 index b6af81dff5..0000000000 --- a/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt +++ /dev/null @@ -1,49 +0,0 @@ -@file:OptIn( - org.jetbrains.compose.resources.InternalResourceApi::class, - org.jetbrains.compose.resources.ExperimentalResourceApi::class, -) - -package app.group.empty_res.generated.resources - -import kotlin.ByteArray -import kotlin.OptIn -import kotlin.String -import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.getResourceUri -import org.jetbrains.compose.resources.readResourceBytes - -internal object Res { - /** - * Reads the content of the resource file at the specified path and returns it as a byte array. - * - * Example: `val bytes = Res.readBytes("files/key.bin")` - * - * @param path The path of the file to read in the compose resource's directory. - * @return The content of the file as a byte array. - */ - @ExperimentalResourceApi - public suspend fun readBytes(path: String): ByteArray = - readResourceBytes("composeResources/app.group.empty_res.generated.resources/" + path) - - /** - * Returns the URI string of the resource file at the specified path. - * - * Example: `val uri = Res.getUri("files/key.bin")` - * - * @param path The path of the file in the compose resource's directory. - * @return The URI string of the file. - */ - @ExperimentalResourceApi - public fun getUri(path: String): String = - getResourceUri("composeResources/app.group.empty_res.generated.resources/" + path) - - public object drawable - - public object string - - public object array - - public object plurals - - public object font -} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonMainResourceCollectors/app/group/empty_res/generated/resources/ExpectResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonMainResourceCollectors/app/group/empty_res/generated/resources/ExpectResourceCollectors.kt new file mode 100644 index 0000000000..ff58b70797 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonMainResourceCollectors/app/group/empty_res/generated/resources/ExpectResourceCollectors.kt @@ -0,0 +1,25 @@ +package app.group.empty_res.generated.resources + +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +internal expect val Res.allDrawableResources: Map + +@ExperimentalResourceApi +internal expect val Res.allStringResources: Map + +@ExperimentalResourceApi +internal expect val Res.allStringArrayResources: Map + +@ExperimentalResourceApi +internal expect val Res.allPluralStringResources: Map + +@ExperimentalResourceApi +internal expect val Res.allFontResources: Map diff --git a/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonResClass/app/group/empty_res/generated/resources/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonResClass/app/group/empty_res/generated/resources/Res.kt new file mode 100644 index 0000000000..32518fbda7 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonResClass/app/group/empty_res/generated/resources/Res.kt @@ -0,0 +1,49 @@ +@file:OptIn( + org.jetbrains.compose.resources.InternalResourceApi::class, + org.jetbrains.compose.resources.ExperimentalResourceApi::class, +) + +package app.group.empty_res.generated.resources + +import kotlin.ByteArray +import kotlin.OptIn +import kotlin.String +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.getResourceUri +import org.jetbrains.compose.resources.readResourceBytes + +internal object Res { + /** + * Reads the content of the resource file at the specified path and returns it as a byte array. + * + * Example: `val bytes = Res.readBytes("files/key.bin")` + * + * @param path The path of the file to read in the compose resource's directory. + * @return The content of the file as a byte array. + */ + @ExperimentalResourceApi + public suspend fun readBytes(path: String): ByteArray = + readResourceBytes("composeResources/app.group.empty_res.generated.resources/" + path) + + /** + * Returns the URI string of the resource file at the specified path. + * + * Example: `val uri = Res.getUri("files/key.bin")` + * + * @param path The path of the file in the compose resource's directory. + * @return The URI string of the file. + */ + @ExperimentalResourceApi + public fun getUri(path: String): String = + getResourceUri("composeResources/app.group.empty_res.generated.resources/" + path) + + public object drawable + + public object string + + public object array + + public object plurals + + public object font +} diff --git a/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/desktopMainResourceCollectors/app/group/empty_res/generated/resources/ActualResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/desktopMainResourceCollectors/app/group/empty_res/generated/resources/ActualResourceCollectors.kt new file mode 100644 index 0000000000..be6a2f9dae --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/desktopMainResourceCollectors/app/group/empty_res/generated/resources/ActualResourceCollectors.kt @@ -0,0 +1,48 @@ +@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) + +package app.group.empty_res.generated.resources + +import kotlin.OptIn +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +internal actual val Res.allDrawableResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allStringResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allStringArrayResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allPluralStringResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal actual val Res.allFontResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + diff --git a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt index 7004b885d8..b532771763 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt @@ -1,6 +1,6 @@ @file:OptIn( - org.jetbrains.compose.resources.InternalResourceApi::class, - org.jetbrains.compose.resources.ExperimentalResourceApi::class, + org.jetbrains.compose.resources.InternalResourceApi::class, + org.jetbrains.compose.resources.ExperimentalResourceApi::class, ) package me.app.jvmonlyresources.generated.resources @@ -13,35 +13,35 @@ import org.jetbrains.compose.resources.getResourceUri import org.jetbrains.compose.resources.readResourceBytes internal object Res { - /** - * Reads the content of the resource file at the specified path and returns it as a byte array. - * - * Example: `val bytes = Res.readBytes("files/key.bin")` - * - * @param path The path of the file to read in the compose resource's directory. - * @return The content of the file as a byte array. - */ - @ExperimentalResourceApi - public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) - - /** - * Returns the URI string of the resource file at the specified path. - * - * Example: `val uri = Res.getUri("files/key.bin")` - * - * @param path The path of the file in the compose resource's directory. - * @return The URI string of the file. - */ - @ExperimentalResourceApi - public fun getUri(path: String): String = getResourceUri("" + path) - - public object drawable - - public object string - - public object array - - public object plurals - - public object font -} \ No newline at end of file + /** + * Reads the content of the resource file at the specified path and returns it as a byte array. + * + * Example: `val bytes = Res.readBytes("files/key.bin")` + * + * @param path The path of the file to read in the compose resource's directory. + * @return The content of the file as a byte array. + */ + @ExperimentalResourceApi + public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) + + /** + * Returns the URI string of the resource file at the specified path. + * + * Example: `val uri = Res.getUri("files/key.bin")` + * + * @param path The path of the file in the compose resource's directory. + * @return The URI string of the file. + */ + @ExperimentalResourceApi + public fun getUri(path: String): String = getResourceUri("" + path) + + public object drawable + + public object string + + public object array + + public object plurals + + public object font +} diff --git a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt index 98f4998f2b..21c01fd922 100644 --- a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt +++ b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt @@ -3,19 +3,27 @@ package me.app.jvmonlyresources.generated.resources import kotlin.OptIn +import kotlin.String +import kotlin.collections.MutableMap import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.InternalResourceApi private object MainDrawable0 { - public val vector: DrawableResource by - lazy { init_vector() } + public val vector: DrawableResource by + lazy { init_vector() } +} + +@InternalResourceApi +internal fun _collectMainDrawable0Resources(map: MutableMap) { + map.put("vector", MainDrawable0.vector) } internal val Res.drawable.vector: DrawableResource - get() = MainDrawable0.vector + get() = MainDrawable0.vector private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( - "drawable:vector", + "drawable:vector", setOf( - org.jetbrains.compose.resources.ResourceItem(setOf(), "drawable/vector.xml", -1, -1), + org.jetbrains.compose.resources.ResourceItem(setOf(), "drawable/vector.xml", -1, -1), ) -) \ No newline at end of file +) diff --git a/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceCollectors/me/app/jvmonlyresources/generated/resources/ActualResourceCollectors.kt b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceCollectors/me/app/jvmonlyresources/generated/resources/ActualResourceCollectors.kt new file mode 100644 index 0000000000..1a915e8926 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceCollectors/me/app/jvmonlyresources/generated/resources/ActualResourceCollectors.kt @@ -0,0 +1,49 @@ +@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) + +package me.app.jvmonlyresources.generated.resources + +import kotlin.OptIn +import kotlin.String +import kotlin.collections.Map +import org.jetbrains.compose.resources.DrawableResource +import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.FontResource +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringArrayResource +import org.jetbrains.compose.resources.StringResource + +@ExperimentalResourceApi +internal val Res.allDrawableResources: Map by lazy { + val map = mutableMapOf() + _collectMainDrawable0Resources(map) + return@lazy map +} + + +@ExperimentalResourceApi +internal val Res.allStringResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal val Res.allStringArrayResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal val Res.allPluralStringResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} + + +@ExperimentalResourceApi +internal val Res.allFontResources: Map by lazy { + val map = mutableMapOf() + return@lazy map +} +