-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate Res class if there is no common composeResource dir (#4176)
- Loading branch information
Showing
8 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
gradle-plugins/compose/src/test/test-projects/misc/emptyResources/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
plugins { | ||
kotlin("multiplatform") | ||
id("org.jetbrains.compose") | ||
} | ||
|
||
group = "app.group" | ||
|
||
kotlin { | ||
jvm("desktop") | ||
|
||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
implementation(compose.runtime) | ||
implementation(compose.material) | ||
implementation(compose.components.resources) | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
gradle-plugins/compose/src/test/test-projects/misc/emptyResources/expected/Res.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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.readResourceBytes | ||
|
||
@OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) | ||
@ExperimentalResourceApi | ||
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. | ||
*/ | ||
public suspend fun readBytes(path: String): ByteArray = readResourceBytes(path) | ||
} |
1 change: 1 addition & 0 deletions
1
gradle-plugins/compose/src/test/test-projects/misc/emptyResources/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.jvmargs=-Xmx8096M |
22 changes: 22 additions & 0 deletions
22
gradle-plugins/compose/src/test/test-projects/misc/emptyResources/settings.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
rootProject.name = "empty_res" | ||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
gradlePluginPortal() | ||
google() | ||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
} | ||
plugins { | ||
id("org.jetbrains.kotlin.multiplatform").version("KOTLIN_VERSION_PLACEHOLDER") | ||
id("org.jetbrains.compose").version("COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER") | ||
} | ||
} | ||
dependencyResolutionManagement { | ||
repositories { | ||
mavenLocal() | ||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
mavenCentral() | ||
gradlePluginPortal() | ||
google() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...e-plugins/compose/src/test/test-projects/misc/emptyResources/src/commonMain/kotlin/App.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import app.group.empty_res.generated.resources.Res | ||
|
||
@Composable | ||
fun App() { | ||
val res = Res | ||
Text("text") | ||
} |