Browse Source

Generate functions to find resources by a string ID. (#5068)

The PR adds a generation special properties with maps a string ID to the
resource for each type of resources:
```kotlin
val Res.allDrawableResources: Map<String, DrawableResource>
val Res.allStringResources: Map<String, StringResource>
val Res.allStringArrayResources: Map<String, StringArrayResource>
val Res.allPluralStringResources: Map<String, PluralStringResource>
val Res.allFontResources: Map<String, FontResource>
```

<!-- Optional -->
Fixes https://github.com/JetBrains/compose-multiplatform/issues/4880
Fixes https://youtrack.jetbrains.com/issue/CMP-1607

## Testing
I checked it in the sample project but this should be tested by QA (KMP
and JVM only projects)

## Release Notes
### Features - Resources
- Now the gradle plugin generates resources map to find a resource by a
string ID
pull/5091/head
Konstantin 4 months ago committed by GitHub
parent
commit
e4c77036db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 136
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ComposeResourcesGeneration.kt
  2. 116
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GenerateResourceCollectorsTask.kt
  3. 108
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt
  4. 4
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt
  5. 22
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceAccessors/my/lib/res/String0.androidMain.kt
  6. 53
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/androidMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt
  7. 90
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Drawable0.commonMain.kt
  8. 24
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Font0.commonMain.kt
  9. 26
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/Plurals0.commonMain.kt
  10. 113
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceAccessors/my/lib/res/String0.commonMain.kt
  11. 25
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonMainResourceCollectors/my/lib/res/ExpectResourceCollectors.kt
  12. 4
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/commonResClass/my/lib/res/Res.kt
  13. 22
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceAccessors/my/lib/res/String0.desktopMain.kt
  14. 53
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected-open-res/desktopMainResourceCollectors/my/lib/res/ActualResourceCollectors.kt
  15. 24
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt
  16. 53
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/androidMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt
  17. 94
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt
  18. 26
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt
  19. 28
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt
  20. 133
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt
  21. 25
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonMainResourceCollectors/app/group/resources_test/generated/resources/ExpectResourceCollectors.kt
  22. 6
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/commonResClass/app/group/resources_test/generated/resources/Res.kt
  23. 24
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceAccessors/app/group/resources_test/generated/resources/String0.desktopMain.kt
  24. 53
      gradle-plugins/compose/src/test/test-projects/misc/commonResources/expected/desktopMainResourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt
  25. 49
      gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt
  26. 25
      gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonMainResourceCollectors/app/group/empty_res/generated/resources/ExpectResourceCollectors.kt
  27. 49
      gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/commonResClass/app/group/empty_res/generated/resources/Res.kt
  28. 48
      gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/desktopMainResourceCollectors/app/group/empty_res/generated/resources/ActualResourceCollectors.kt
  29. 68
      gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt
  30. 20
      gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceAccessors/me/app/jvmonlyresources/generated/resources/Drawable0.main.kt
  31. 49
      gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/mainResourceCollectors/me/app/jvmonlyresources/generated/resources/ActualResourceCollectors.kt

136
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.IDEA_IMPORT_TASK_NAME
import org.jetbrains.compose.internal.IdeaImportTask import org.jetbrains.compose.internal.IdeaImportTask
import org.jetbrains.compose.internal.utils.uppercaseFirstChar 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.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.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 import java.io.File
internal fun Project.configureComposeResourcesGeneration( internal fun Project.configureComposeResourcesGeneration(
@ -67,6 +73,8 @@ internal fun Project.configureComposeResourcesGeneration(
) )
} }
configureResourceCollectorsGeneration(kotlinExtension, shouldGenerateCode, packageName, makeAccessorsPublic)
//setup task execution during IDE import //setup task execution during IDE import
tasks.configureEach { importTask -> tasks.configureEach { importTask ->
if (importTask.name == IDEA_IMPORT_TASK_NAME) { if (importTask.name == IDEA_IMPORT_TASK_NAME) {
@ -115,7 +123,7 @@ private fun Project.configureResourceAccessorsGeneration(
logger.info("Configure resource accessors generation for ${sourceSet.name}") logger.info("Configure resource accessors generation for ${sourceSet.name}")
val genTask = tasks.register( val genTask = tasks.register(
"generateResourceAccessorsFor${sourceSet.name.uppercaseFirstChar()}", sourceSet.getResourceAccessorsGenerationTaskName(),
GenerateResourceAccessorsTask::class.java GenerateResourceAccessorsTask::class.java
) { task -> ) { task ->
task.packageName.set(packageName) 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<Boolean>,
packageName: Provider<String>,
makeAccessorsPublic: Provider<Boolean>
) {
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<Boolean>,
packageName: Provider<String>,
makeAccessorsPublic: Provider<Boolean>
) {
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<Boolean>,
packageName: Provider<String>,
makeAccessorsPublic: Provider<Boolean>,
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 //register generated source set
sourceSet.kotlin.srcDir(genTask.map { it.codeDir }) sourceSet.kotlin.srcDir(genTask.map { it.codeDir })
} }

116
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<String>
@get:Input
abstract val shouldGenerateCode: Property<Boolean>
@get:Input
abstract val makeAccessorsPublic: Property<Boolean>
@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<String>
@get:Input
abstract val shouldGenerateCode: Property<Boolean>
@get:Input
abstract val makeAccessorsPublic: Property<Boolean>
@get:Input
abstract val useActualModifier: Property<Boolean>
@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")
}
}
}

108
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/GeneratedResClassSpec.kt

@ -1,6 +1,19 @@
package org.jetbrains.compose.resources 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 org.jetbrains.compose.internal.utils.uppercaseFirstChar
import java.nio.file.Path import java.nio.file.Path
import java.util.* import java.util.*
@ -45,6 +58,9 @@ private val resourceItemClass = ClassName("org.jetbrains.compose.resources", "Re
private val experimentalAnnotation = AnnotationSpec.builder( private val experimentalAnnotation = AnnotationSpec.builder(
ClassName("org.jetbrains.compose.resources", "ExperimentalResourceApi") ClassName("org.jetbrains.compose.resources", "ExperimentalResourceApi")
).build() ).build()
private val internalAnnotation = AnnotationSpec.builder(
ClassName("org.jetbrains.compose.resources", "InternalResourceApi")
).build()
private fun CodeBlock.Builder.addQualifiers(resourceItem: ResourceItem): CodeBlock.Builder { private fun CodeBlock.Builder.addQualifiers(resourceItem: ResourceItem): CodeBlock.Builder {
val languageQualifier = ClassName("org.jetbrains.compose.resources", "LanguageQualifier") val languageQualifier = ClassName("org.jetbrains.compose.resources", "LanguageQualifier")
@ -247,6 +263,23 @@ private fun getChunkFileSpec(
}.build() }.build()
chunkFile.addType(objectSpec) 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) -> idToResources.forEach { (resName, items) ->
val accessor = PropertySpec.builder(resName, type.getClassName(), resModifier) val accessor = PropertySpec.builder(resName, type.getClassName(), resModifier)
.receiver(ClassName(packageName, "Res", type.accessorName)) .receiver(ClassName(packageName, "Res", type.accessorName))
@ -285,6 +318,79 @@ private fun getChunkFileSpec(
}.build() }.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<ResourceType, List<String>>
): 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<String, %T>()", 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( private fun sortResources(
resources: Map<ResourceType, Map<String, List<ResourceItem>>> resources: Map<ResourceType, Map<String, List<ResourceItem>>>
): TreeMap<ResourceType, TreeMap<String, List<ResourceItem>>> { ): TreeMap<ResourceType, TreeMap<String, List<ResourceItem>>> {

4
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt

@ -513,9 +513,9 @@ class ResourcesTest : GradlePluginTestBase() {
@Test @Test
fun testEmptyResClass(): Unit = with(testProject("misc/emptyResources")) { fun testEmptyResClass(): Unit = with(testProject("misc/emptyResources")) {
gradle("generateComposeResClass").checks { gradle("prepareKotlinIdeaImport").checks {
assertDirectoriesContentEquals( assertDirectoriesContentEquals(
file("build/generated/compose/resourceGenerator/kotlin/commonResClass/app/group/empty_res/generated/resources"), file("build/generated/compose/resourceGenerator/kotlin"),
file("expected") file("expected")
) )
} }

22
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
private object AndroidMainString0 { private object AndroidMainString0 {
public val android_str: StringResource by public val android_str: StringResource by
lazy { init_android_str() } lazy { init_android_str() }
}
@InternalResourceApi
internal fun _collectAndroidMainString0Resources(map: MutableMap<String, StringResource>) {
map.put("android_str", AndroidMainString0.android_str)
} }
public val Res.string.android_str: StringResource 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( private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:android_str", "android_str", "string:android_str", "android_str",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.androidMain.cvr", 10, 39), "composeResources/my.lib.res/values/strings.androidMain.cvr", 10, 39),
) )
) )

53
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<String, DrawableResource> by lazy {
val map = mutableMapOf<String, DrawableResource>()
_collectCommonMainDrawable0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allStringResources: Map<String, StringResource> by lazy {
val map = mutableMapOf<String, StringResource>()
_collectAndroidMainString0Resources(map)
_collectCommonMainString0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy {
val map = mutableMapOf<String, StringArrayResource>()
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy {
val map = mutableMapOf<String, PluralStringResource>()
_collectCommonMainPlurals0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allFontResources: Map<String, FontResource> by lazy {
val map = mutableMapOf<String, FontResource>()
_collectCommonMainFont0Resources(map)
return@lazy map
}

90
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.InternalResourceApi
private object CommonMainDrawable0 { private object CommonMainDrawable0 {
public val _3_strange_name: DrawableResource by public val _3_strange_name: DrawableResource by
lazy { init__3_strange_name() } lazy { init__3_strange_name() }
public val camelCaseName: DrawableResource by public val camelCaseName: DrawableResource by
lazy { init_camelCaseName() } lazy { init_camelCaseName() }
public val `is`: DrawableResource by public val `is`: DrawableResource by
lazy { init_is() } lazy { init_is() }
public val vector: DrawableResource by public val vector: DrawableResource by
lazy { init_vector() } lazy { init_vector() }
public val vector_2: DrawableResource by public val vector_2: DrawableResource by
lazy { init_vector_2() } lazy { init_vector_2() }
}
@InternalResourceApi
internal fun _collectCommonMainDrawable0Resources(map: MutableMap<String, DrawableResource>) {
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 public val Res.drawable._3_strange_name: DrawableResource
get() = CommonMainDrawable0._3_strange_name get() = CommonMainDrawable0._3_strange_name
private fun init__3_strange_name(): DrawableResource = private fun init__3_strange_name(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:_3_strange_name", "drawable:_3_strange_name",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(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 public val Res.drawable.camelCaseName: DrawableResource
get() = CommonMainDrawable0.camelCaseName get() = CommonMainDrawable0.camelCaseName
private fun init_camelCaseName(): DrawableResource = private fun init_camelCaseName(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:camelCaseName", "drawable:camelCaseName",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(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 public val Res.drawable.`is`: DrawableResource
get() = CommonMainDrawable0.`is` get() = CommonMainDrawable0.`is`
private fun init_is(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_is(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:is", "drawable:is",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/drawable/is.xml", -1, -1), "composeResources/my.lib.res/drawable/is.xml", -1, -1),
) )
) )
public val Res.drawable.vector: DrawableResource 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( private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector", "drawable:vector",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("ast"), org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("ast"),
), "composeResources/my.lib.res/drawable-ast/vector.xml", -1, -1), ), "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.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("au"),
org.jetbrains.compose.resources.RegionQualifier("US"), ), org.jetbrains.compose.resources.RegionQualifier("US"), ),
"composeResources/my.lib.res/drawable-au-rUS/vector.xml", -1, -1), "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.ResourceItem(setOf(org.jetbrains.compose.resources.ThemeQualifier.DARK,
org.jetbrains.compose.resources.LanguageQualifier("ge"), ), org.jetbrains.compose.resources.LanguageQualifier("ge"), ),
"composeResources/my.lib.res/drawable-dark-ge/vector.xml", -1, -1), "composeResources/my.lib.res/drawable-dark-ge/vector.xml", -1, -1),
org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"), org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"),
), "composeResources/my.lib.res/drawable-en/vector.xml", -1, -1), ), "composeResources/my.lib.res/drawable-en/vector.xml", -1, -1),
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/drawable/vector.xml", -1, -1), "composeResources/my.lib.res/drawable/vector.xml", -1, -1),
) )
) )
public val Res.drawable.vector_2: DrawableResource 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( private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector_2", "drawable:vector_2",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/drawable/vector_2.xml", -1, -1), "composeResources/my.lib.res/drawable/vector_2.xml", -1, -1),
) )
) )

24
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.FontResource import org.jetbrains.compose.resources.FontResource
import org.jetbrains.compose.resources.InternalResourceApi
private object CommonMainFont0 { private object CommonMainFont0 {
public val emptyFont: FontResource by public val emptyFont: FontResource by
lazy { init_emptyFont() } lazy { init_emptyFont() }
}
@InternalResourceApi
internal fun _collectCommonMainFont0Resources(map: MutableMap<String, FontResource>) {
map.put("emptyFont", CommonMainFont0.emptyFont)
} }
public val Res.font.emptyFont: FontResource 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( private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource(
"font:emptyFont", "font:emptyFont",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"), org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"),
), "composeResources/my.lib.res/font-en/emptyFont.otf", -1, -1), ), "composeResources/my.lib.res/font-en/emptyFont.otf", -1, -1),
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/font/emptyFont.otf", -1, -1), "composeResources/my.lib.res/font/emptyFont.otf", -1, -1),
) )
) )

26
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.PluralStringResource import org.jetbrains.compose.resources.PluralStringResource
private object CommonMainPlurals0 { private object CommonMainPlurals0 {
public val numberOfSongsAvailable: PluralStringResource by public val numberOfSongsAvailable: PluralStringResource by
lazy { init_numberOfSongsAvailable() } lazy { init_numberOfSongsAvailable() }
}
@InternalResourceApi
internal fun _collectCommonMainPlurals0Resources(map: MutableMap<String, PluralStringResource>) {
map.put("numberOfSongsAvailable", CommonMainPlurals0.numberOfSongsAvailable)
} }
public val Res.plurals.numberOfSongsAvailable: PluralStringResource public val Res.plurals.numberOfSongsAvailable: PluralStringResource
get() = CommonMainPlurals0.numberOfSongsAvailable get() = CommonMainPlurals0.numberOfSongsAvailable
private fun init_numberOfSongsAvailable(): PluralStringResource = private fun init_numberOfSongsAvailable(): PluralStringResource =
org.jetbrains.compose.resources.PluralStringResource( org.jetbrains.compose.resources.PluralStringResource(
"plurals:numberOfSongsAvailable", "numberOfSongsAvailable", "plurals:numberOfSongsAvailable", "numberOfSongsAvailable",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 10, 124), "composeResources/my.lib.res/values/strings.commonMain.cvr", 10, 124),
) )
) )

113
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
private object CommonMainString0 { private object CommonMainString0 {
public val PascalCase: StringResource by public val PascalCase: StringResource by
lazy { init_PascalCase() } lazy { init_PascalCase() }
public val _1_kebab_case: StringResource by public val _1_kebab_case: StringResource by
lazy { init__1_kebab_case() } lazy { init__1_kebab_case() }
public val app_name: StringResource by public val app_name: StringResource by
lazy { init_app_name() } lazy { init_app_name() }
public val camelCase: StringResource by public val camelCase: StringResource by
lazy { init_camelCase() } lazy { init_camelCase() }
public val hello: StringResource by public val hello: StringResource by
lazy { init_hello() } lazy { init_hello() }
public val `info_using_release_$x`: StringResource by public val `info_using_release_$x`: StringResource by
lazy { `init_info_using_release_$x`() } lazy { `init_info_using_release_$x`() }
public val multi_line: StringResource by public val multi_line: StringResource by
lazy { init_multi_line() } lazy { init_multi_line() }
public val str_template: StringResource by public val str_template: StringResource by
lazy { init_str_template() } lazy { init_str_template() }
}
@InternalResourceApi
internal fun _collectCommonMainString0Resources(map: MutableMap<String, StringResource>) {
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 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( private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:PascalCase", "PascalCase", "string:PascalCase", "PascalCase",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 172, 34), "composeResources/my.lib.res/values/strings.commonMain.cvr", 172, 34),
) )
) )
public val Res.string._1_kebab_case: StringResource 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( 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( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 135, 36), "composeResources/my.lib.res/values/strings.commonMain.cvr", 135, 36),
) )
) )
public val Res.string.app_name: StringResource 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( private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:app_name", "app_name", "string:app_name", "app_name",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 207, 44), "composeResources/my.lib.res/values/strings.commonMain.cvr", 207, 44),
) )
) )
public val Res.string.camelCase: StringResource 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( private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:camelCase", "camelCase", "string:camelCase", "camelCase",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 252, 29), "composeResources/my.lib.res/values/strings.commonMain.cvr", 252, 29),
) )
) )
public val Res.string.hello: StringResource 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( private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:hello", "hello", "string:hello", "hello",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 282, 37), "composeResources/my.lib.res/values/strings.commonMain.cvr", 282, 37),
) )
) )
public val Res.string.`info_using_release_$x`: StringResource public 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 = private fun `init_info_using_release_$x`(): StringResource =
org.jetbrains.compose.resources.StringResource( org.jetbrains.compose.resources.StringResource(
"string:info_using_release_${'$'}x", "info_using_release_${'$'}x", "string:info_using_release_${'$'}x", "info_using_release_${'$'}x",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(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 public 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( private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:multi_line", "multi_line", "string:multi_line", "multi_line",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 378, 178), "composeResources/my.lib.res/values/strings.commonMain.cvr", 378, 178),
) )
) )
public val Res.string.str_template: StringResource 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( private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:str_template", "str_template", "string:str_template", "str_template",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/strings.commonMain.cvr", 557, 76), "composeResources/my.lib.res/values/strings.commonMain.cvr", 557, 76),
) )
) )

25
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<String, DrawableResource>
@ExperimentalResourceApi
public expect val Res.allStringResources: Map<String, StringResource>
@ExperimentalResourceApi
public expect val Res.allStringArrayResources: Map<String, StringArrayResource>
@ExperimentalResourceApi
public expect val Res.allPluralStringResources: Map<String, PluralStringResource>
@ExperimentalResourceApi
public expect val Res.allFontResources: Map<String, FontResource>

4
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 @ExperimentalResourceApi
public suspend fun readBytes(path: String): ByteArray = 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. * Returns the URI string of the resource file at the specified path.
@ -45,4 +45,4 @@ public object Res {
public object plurals public object plurals
public object font public object font
} }

22
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 package my.lib.res
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
private object DesktopMainString0 { private object DesktopMainString0 {
public val desktop_str: StringResource by public val desktop_str: StringResource by
lazy { init_desktop_str() } lazy { init_desktop_str() }
}
@InternalResourceApi
internal fun _collectDesktopMainString0Resources(map: MutableMap<String, StringResource>) {
map.put("desktop_str", DesktopMainString0.desktop_str)
} }
public val Res.string.desktop_str: StringResource 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( private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:desktop_str", "desktop_str", "string:desktop_str", "desktop_str",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/my.lib.res/values/desktop_strings.desktopMain.cvr", 10, 39), "composeResources/my.lib.res/values/desktop_strings.desktopMain.cvr", 10, 39),
) )
) )

53
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<String, DrawableResource> by lazy {
val map = mutableMapOf<String, DrawableResource>()
_collectCommonMainDrawable0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allStringResources: Map<String, StringResource> by lazy {
val map = mutableMapOf<String, StringResource>()
_collectDesktopMainString0Resources(map)
_collectCommonMainString0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy {
val map = mutableMapOf<String, StringArrayResource>()
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy {
val map = mutableMapOf<String, PluralStringResource>()
_collectCommonMainPlurals0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
public actual val Res.allFontResources: Map<String, FontResource> by lazy {
val map = mutableMapOf<String, FontResource>()
_collectCommonMainFont0Resources(map)
return@lazy map
}

24
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
private object AndroidMainString0 { private object AndroidMainString0 {
public val android_str: StringResource by public val android_str: StringResource by
lazy { init_android_str() } lazy { init_android_str() }
}
@InternalResourceApi
internal fun _collectAndroidMainString0Resources(map: MutableMap<String, StringResource>) {
map.put("android_str", AndroidMainString0.android_str)
} }
internal val Res.string.android_str: StringResource 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( private fun init_android_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:android_str", "android_str", "string:android_str", "android_str",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.androidMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.androidMain.cvr",
10, 39), 10, 39),
) )
) )

53
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<String, DrawableResource> by lazy {
val map = mutableMapOf<String, DrawableResource>()
_collectCommonMainDrawable0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allStringResources: Map<String, StringResource> by lazy {
val map = mutableMapOf<String, StringResource>()
_collectAndroidMainString0Resources(map)
_collectCommonMainString0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy {
val map = mutableMapOf<String, StringArrayResource>()
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy {
val map = mutableMapOf<String, PluralStringResource>()
_collectCommonMainPlurals0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allFontResources: Map<String, FontResource> by lazy {
val map = mutableMapOf<String, FontResource>()
_collectCommonMainFont0Resources(map)
return@lazy map
}

94
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.InternalResourceApi
private object CommonMainDrawable0 { private object CommonMainDrawable0 {
public val _3_strange_name: DrawableResource by public val _3_strange_name: DrawableResource by
lazy { init__3_strange_name() } lazy { init__3_strange_name() }
public val camelCaseName: DrawableResource by public val camelCaseName: DrawableResource by
lazy { init_camelCaseName() } lazy { init_camelCaseName() }
public val `is`: DrawableResource by public val `is`: DrawableResource by
lazy { init_is() } lazy { init_is() }
public val vector: DrawableResource by public val vector: DrawableResource by
lazy { init_vector() } lazy { init_vector() }
public val vector_2: DrawableResource by public val vector_2: DrawableResource by
lazy { init_vector_2() } lazy { init_vector_2() }
}
@InternalResourceApi
internal fun _collectCommonMainDrawable0Resources(map: MutableMap<String, DrawableResource>) {
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 internal val Res.drawable._3_strange_name: DrawableResource
get() = CommonMainDrawable0._3_strange_name get() = CommonMainDrawable0._3_strange_name
private fun init__3_strange_name(): DrawableResource = private fun init__3_strange_name(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:_3_strange_name", "drawable:_3_strange_name",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(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 internal val Res.drawable.camelCaseName: DrawableResource
get() = CommonMainDrawable0.camelCaseName get() = CommonMainDrawable0.camelCaseName
private fun init_camelCaseName(): DrawableResource = private fun init_camelCaseName(): DrawableResource =
org.jetbrains.compose.resources.DrawableResource( org.jetbrains.compose.resources.DrawableResource(
"drawable:camelCaseName", "drawable:camelCaseName",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(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 internal val Res.drawable.`is`: DrawableResource
get() = CommonMainDrawable0.`is` get() = CommonMainDrawable0.`is`
private fun init_is(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_is(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:is", "drawable:is",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/drawable/is.xml", -1, -1), "composeResources/app.group.resources_test.generated.resources/drawable/is.xml", -1, -1),
) )
) )
internal val Res.drawable.vector: DrawableResource 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( private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector", "drawable:vector",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("ast"), 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.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("au"),
org.jetbrains.compose.resources.RegionQualifier("US"), ), org.jetbrains.compose.resources.RegionQualifier("US"), ),
"composeResources/app.group.resources_test.generated.resources/drawable-au-rUS/vector.xml", -1, -1), "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.ResourceItem(setOf(org.jetbrains.compose.resources.ThemeQualifier.DARK,
org.jetbrains.compose.resources.LanguageQualifier("ge"), ), org.jetbrains.compose.resources.LanguageQualifier("ge"), ),
"composeResources/app.group.resources_test.generated.resources/drawable-dark-ge/vector.xml", -1, -1), "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"), 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), "composeResources/app.group.resources_test.generated.resources/drawable-en/vector.xml", -1, -1),
org.jetbrains.compose.resources.ResourceItem(setOf(), 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/vector.xml", -1, -1),
) )
) )
internal val Res.drawable.vector_2: DrawableResource 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( private fun init_vector_2(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector_2", "drawable:vector_2",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/drawable/vector_2.xml", -1, -1), "composeResources/app.group.resources_test.generated.resources/drawable/vector_2.xml", -1, -1),
) )
) )

26
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.FontResource import org.jetbrains.compose.resources.FontResource
import org.jetbrains.compose.resources.InternalResourceApi
private object CommonMainFont0 { private object CommonMainFont0 {
public val emptyFont: FontResource by public val emptyFont: FontResource by
lazy { init_emptyFont() } lazy { init_emptyFont() }
}
@InternalResourceApi
internal fun _collectCommonMainFont0Resources(map: MutableMap<String, FontResource>) {
map.put("emptyFont", CommonMainFont0.emptyFont)
} }
internal val Res.font.emptyFont: FontResource 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( private fun init_emptyFont(): FontResource = org.jetbrains.compose.resources.FontResource(
"font:emptyFont", "font:emptyFont",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(org.jetbrains.compose.resources.LanguageQualifier("en"), 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), "composeResources/app.group.resources_test.generated.resources/font-en/emptyFont.otf", -1, -1),
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/font/emptyFont.otf", -1, -1), "composeResources/app.group.resources_test.generated.resources/font/emptyFont.otf", -1, -1),
) )
) )

28
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.PluralStringResource import org.jetbrains.compose.resources.PluralStringResource
private object CommonMainPlurals0 { private object CommonMainPlurals0 {
public val numberOfSongsAvailable: PluralStringResource by public val numberOfSongsAvailable: PluralStringResource by
lazy { init_numberOfSongsAvailable() } lazy { init_numberOfSongsAvailable() }
}
@InternalResourceApi
internal fun _collectCommonMainPlurals0Resources(map: MutableMap<String, PluralStringResource>) {
map.put("numberOfSongsAvailable", CommonMainPlurals0.numberOfSongsAvailable)
} }
internal val Res.plurals.numberOfSongsAvailable: PluralStringResource internal val Res.plurals.numberOfSongsAvailable: PluralStringResource
get() = CommonMainPlurals0.numberOfSongsAvailable get() = CommonMainPlurals0.numberOfSongsAvailable
private fun init_numberOfSongsAvailable(): PluralStringResource = private fun init_numberOfSongsAvailable(): PluralStringResource =
org.jetbrains.compose.resources.PluralStringResource( org.jetbrains.compose.resources.PluralStringResource(
"plurals:numberOfSongsAvailable", "numberOfSongsAvailable", "plurals:numberOfSongsAvailable", "numberOfSongsAvailable",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
10, 124), 10, 124),
) )
) )

133
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
private object CommonMainString0 { private object CommonMainString0 {
public val PascalCase: StringResource by public val PascalCase: StringResource by
lazy { init_PascalCase() } lazy { init_PascalCase() }
public val _1_kebab_case: StringResource by public val _1_kebab_case: StringResource by
lazy { init__1_kebab_case() } lazy { init__1_kebab_case() }
public val app_name: StringResource by public val app_name: StringResource by
lazy { init_app_name() } lazy { init_app_name() }
public val camelCase: StringResource by public val camelCase: StringResource by
lazy { init_camelCase() } lazy { init_camelCase() }
public val hello: StringResource by public val hello: StringResource by
lazy { init_hello() } lazy { init_hello() }
public val `info_using_release_$x`: StringResource by public val `info_using_release_$x`: StringResource by
lazy { `init_info_using_release_$x`() } lazy { `init_info_using_release_$x`() }
public val multi_line: StringResource by public val multi_line: StringResource by
lazy { init_multi_line() } lazy { init_multi_line() }
public val str_template: StringResource by public val str_template: StringResource by
lazy { init_str_template() } lazy { init_str_template() }
}
@InternalResourceApi
internal fun _collectCommonMainString0Resources(map: MutableMap<String, StringResource>) {
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 internal val Res.string.PascalCase: StringResource
get() = CommonMainString0.PascalCase get() = CommonMainString0.PascalCase
private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_PascalCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:PascalCase", "PascalCase", "string:PascalCase", "PascalCase",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
172, 34), 172, 34),
) )
) )
internal val Res.string._1_kebab_case: StringResource 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( 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( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
135, 36), 135, 36),
) )
) )
internal val Res.string.app_name: StringResource 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( private fun init_app_name(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:app_name", "app_name", "string:app_name", "app_name",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
207, 44), 207, 44),
) )
) )
internal val Res.string.camelCase: StringResource internal val Res.string.camelCase: StringResource
get() = CommonMainString0.camelCase get() = CommonMainString0.camelCase
private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_camelCase(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:camelCase", "camelCase", "string:camelCase", "camelCase",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
252, 29), 252, 29),
) )
) )
internal val Res.string.hello: StringResource internal val Res.string.hello: StringResource
get() = CommonMainString0.hello get() = CommonMainString0.hello
private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource( private fun init_hello(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:hello", "hello", "string:hello", "hello",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
282, 37), 282, 37),
) )
) )
internal val Res.string.`info_using_release_$x`: StringResource 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 = private fun `init_info_using_release_$x`(): StringResource =
org.jetbrains.compose.resources.StringResource( org.jetbrains.compose.resources.StringResource(
"string:info_using_release_${'$'}x", "info_using_release_${'$'}x", "string:info_using_release_${'$'}x", "info_using_release_${'$'}x",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
320, 57), 320, 57),
)
) )
)
internal val Res.string.multi_line: StringResource 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( private fun init_multi_line(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:multi_line", "multi_line", "string:multi_line", "multi_line",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
378, 178), 378, 178),
) )
) )
internal val Res.string.str_template: StringResource 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( private fun init_str_template(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:str_template", "str_template", "string:str_template", "str_template",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/strings.commonMain.cvr",
557, 76), 557, 76),
) )
) )

25
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<String, DrawableResource>
@ExperimentalResourceApi
internal expect val Res.allStringResources: Map<String, StringResource>
@ExperimentalResourceApi
internal expect val Res.allStringArrayResources: Map<String, StringArrayResource>
@ExperimentalResourceApi
internal expect val Res.allPluralStringResources: Map<String, PluralStringResource>
@ExperimentalResourceApi
internal expect val Res.allFontResources: Map<String, FontResource>

6
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 @ExperimentalResourceApi
public suspend fun readBytes(path: String): ByteArray = 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. * Returns the URI string of the resource file at the specified path.
@ -35,7 +35,7 @@ internal object Res {
*/ */
@ExperimentalResourceApi @ExperimentalResourceApi
public fun getUri(path: String): String = 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 public object drawable
@ -46,4 +46,4 @@ internal object Res {
public object plurals public object plurals
public object font public object font
} }

24
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 package app.group.resources_test.generated.resources
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.InternalResourceApi
import org.jetbrains.compose.resources.StringResource import org.jetbrains.compose.resources.StringResource
private object DesktopMainString0 { private object DesktopMainString0 {
public val desktop_str: StringResource by public val desktop_str: StringResource by
lazy { init_desktop_str() } lazy { init_desktop_str() }
}
@InternalResourceApi
internal fun _collectDesktopMainString0Resources(map: MutableMap<String, StringResource>) {
map.put("desktop_str", DesktopMainString0.desktop_str)
} }
internal val Res.string.desktop_str: StringResource 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( private fun init_desktop_str(): StringResource = org.jetbrains.compose.resources.StringResource(
"string:desktop_str", "desktop_str", "string:desktop_str", "desktop_str",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), org.jetbrains.compose.resources.ResourceItem(setOf(),
"composeResources/app.group.resources_test.generated.resources/values/desktop_strings.desktopMain.cvr", "composeResources/app.group.resources_test.generated.resources/values/desktop_strings.desktopMain.cvr",
10, 39), 10, 39),
) )
) )

53
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<String, DrawableResource> by lazy {
val map = mutableMapOf<String, DrawableResource>()
_collectCommonMainDrawable0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allStringResources: Map<String, StringResource> by lazy {
val map = mutableMapOf<String, StringResource>()
_collectDesktopMainString0Resources(map)
_collectCommonMainString0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy {
val map = mutableMapOf<String, StringArrayResource>()
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy {
val map = mutableMapOf<String, PluralStringResource>()
_collectCommonMainPlurals0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allFontResources: Map<String, FontResource> by lazy {
val map = mutableMapOf<String, FontResource>()
_collectCommonMainFont0Resources(map)
return@lazy map
}

49
gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt

@ -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
}

25
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<String, DrawableResource>
@ExperimentalResourceApi
internal expect val Res.allStringResources: Map<String, StringResource>
@ExperimentalResourceApi
internal expect val Res.allStringArrayResources: Map<String, StringArrayResource>
@ExperimentalResourceApi
internal expect val Res.allPluralStringResources: Map<String, PluralStringResource>
@ExperimentalResourceApi
internal expect val Res.allFontResources: Map<String, FontResource>

49
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
}

48
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<String, DrawableResource> by lazy {
val map = mutableMapOf<String, DrawableResource>()
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allStringResources: Map<String, StringResource> by lazy {
val map = mutableMapOf<String, StringResource>()
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy {
val map = mutableMapOf<String, StringArrayResource>()
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy {
val map = mutableMapOf<String, PluralStringResource>()
return@lazy map
}
@ExperimentalResourceApi
internal actual val Res.allFontResources: Map<String, FontResource> by lazy {
val map = mutableMapOf<String, FontResource>()
return@lazy map
}

68
gradle-plugins/compose/src/test/test-projects/misc/jvmOnlyResources/expected/commonResClass/me/app/jvmonlyresources/generated/resources/Res.kt

@ -1,6 +1,6 @@
@file:OptIn( @file:OptIn(
org.jetbrains.compose.resources.InternalResourceApi::class, org.jetbrains.compose.resources.InternalResourceApi::class,
org.jetbrains.compose.resources.ExperimentalResourceApi::class, org.jetbrains.compose.resources.ExperimentalResourceApi::class,
) )
package me.app.jvmonlyresources.generated.resources package me.app.jvmonlyresources.generated.resources
@ -13,35 +13,35 @@ import org.jetbrains.compose.resources.getResourceUri
import org.jetbrains.compose.resources.readResourceBytes import org.jetbrains.compose.resources.readResourceBytes
internal object Res { internal object Res {
/** /**
* Reads the content of the resource file at the specified path and returns it as a byte array. * 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")` * Example: `val bytes = Res.readBytes("files/key.bin")`
* *
* @param path The path of the file to read in the compose resource's directory. * @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. * @return The content of the file as a byte array.
*/ */
@ExperimentalResourceApi @ExperimentalResourceApi
public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path) public suspend fun readBytes(path: String): ByteArray = readResourceBytes("" + path)
/** /**
* Returns the URI string of the resource file at the specified path. * Returns the URI string of the resource file at the specified path.
* *
* Example: `val uri = Res.getUri("files/key.bin")` * Example: `val uri = Res.getUri("files/key.bin")`
* *
* @param path The path of the file in the compose resource's directory. * @param path The path of the file in the compose resource's directory.
* @return The URI string of the file. * @return The URI string of the file.
*/ */
@ExperimentalResourceApi @ExperimentalResourceApi
public fun getUri(path: String): String = getResourceUri("" + path) public fun getUri(path: String): String = getResourceUri("" + path)
public object drawable public object drawable
public object string public object string
public object array public object array
public object plurals public object plurals
public object font public object font
} }

20
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 package me.app.jvmonlyresources.generated.resources
import kotlin.OptIn import kotlin.OptIn
import kotlin.String
import kotlin.collections.MutableMap
import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.InternalResourceApi
private object MainDrawable0 { private object MainDrawable0 {
public val vector: DrawableResource by public val vector: DrawableResource by
lazy { init_vector() } lazy { init_vector() }
}
@InternalResourceApi
internal fun _collectMainDrawable0Resources(map: MutableMap<String, DrawableResource>) {
map.put("vector", MainDrawable0.vector)
} }
internal val Res.drawable.vector: DrawableResource internal val Res.drawable.vector: DrawableResource
get() = MainDrawable0.vector get() = MainDrawable0.vector
private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource( private fun init_vector(): DrawableResource = org.jetbrains.compose.resources.DrawableResource(
"drawable:vector", "drawable:vector",
setOf( setOf(
org.jetbrains.compose.resources.ResourceItem(setOf(), "drawable/vector.xml", -1, -1), org.jetbrains.compose.resources.ResourceItem(setOf(), "drawable/vector.xml", -1, -1),
) )
) )

49
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<String, DrawableResource> by lazy {
val map = mutableMapOf<String, DrawableResource>()
_collectMainDrawable0Resources(map)
return@lazy map
}
@ExperimentalResourceApi
internal val Res.allStringResources: Map<String, StringResource> by lazy {
val map = mutableMapOf<String, StringResource>()
return@lazy map
}
@ExperimentalResourceApi
internal val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy {
val map = mutableMapOf<String, StringArrayResource>()
return@lazy map
}
@ExperimentalResourceApi
internal val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy {
val map = mutableMapOf<String, PluralStringResource>()
return@lazy map
}
@ExperimentalResourceApi
internal val Res.allFontResources: Map<String, FontResource> by lazy {
val map = mutableMapOf<String, FontResource>()
return@lazy map
}
Loading…
Cancel
Save