Konstantin Tskhovrebov
3 months ago
14 changed files with 270 additions and 23 deletions
@ -0,0 +1,89 @@
|
||||
import org.jetbrains.compose.ExperimentalComposeLibrary |
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi |
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree |
||||
|
||||
plugins { |
||||
id("org.jetbrains.compose") |
||||
kotlin("multiplatform") |
||||
id("com.android.application") |
||||
} |
||||
|
||||
kotlin { |
||||
androidTarget { |
||||
@OptIn(ExperimentalKotlinGradlePluginApi::class) |
||||
instrumentedTestVariant { |
||||
sourceSetTree.set(KotlinSourceSetTree.test) |
||||
dependencies { |
||||
implementation("androidx.compose.ui:ui-test-junit4-android:1.6.2") |
||||
debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.2") |
||||
} |
||||
} |
||||
} |
||||
jvm() |
||||
iosX64() |
||||
iosArm64() |
||||
iosSimulatorArm64() |
||||
js { browser() } |
||||
wasmJs { browser() } |
||||
|
||||
sourceSets { |
||||
all { |
||||
languageSettings { |
||||
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi") |
||||
} |
||||
} |
||||
|
||||
commonMain.dependencies { |
||||
implementation(compose.runtime) |
||||
implementation(compose.material3) |
||||
implementation(compose.components.resources) |
||||
implementation("me.sample.library:cmplib:1.0") |
||||
implementation(project(":featureModule")) |
||||
} |
||||
|
||||
jvmMain.dependencies { |
||||
implementation(compose.desktop.currentOs) |
||||
} |
||||
|
||||
commonTest.dependencies { |
||||
implementation(kotlin("test")) |
||||
@OptIn(ExperimentalComposeLibrary::class) |
||||
implementation(compose.uiTest) |
||||
} |
||||
} |
||||
} |
||||
|
||||
android { |
||||
namespace = "me.sample.app" |
||||
compileSdk = 34 |
||||
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") |
||||
defaultConfig { |
||||
applicationId = "org.example.project" |
||||
minSdk = 24 |
||||
targetSdk = 34 |
||||
versionCode = 1 |
||||
versionName = "1.0" |
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
||||
} |
||||
@Suppress("UnstableApiUsage") |
||||
testOptions { |
||||
managedDevices { |
||||
devices { |
||||
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel5").apply { |
||||
device = "Pixel 5" |
||||
apiLevel = 34 |
||||
systemImageSource = "aosp" |
||||
} |
||||
} |
||||
} |
||||
} |
||||
compileOptions { |
||||
sourceCompatibility = JavaVersion.VERSION_17 |
||||
targetCompatibility = JavaVersion.VERSION_17 |
||||
} |
||||
} |
||||
|
||||
compose { |
||||
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("COMPOSE_COMPILER_PLUGIN_PLACEHOLDER")) |
||||
kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=KOTLIN_VERSION_PLACEHOLDER") |
||||
} |
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<manifest> |
||||
<application/> |
||||
</manifest> |
@ -0,0 +1,3 @@
|
||||
<resources> |
||||
<string name="str_1">App text str_1</string> |
||||
</resources> |
@ -0,0 +1,21 @@
|
||||
package me.sample.app |
||||
|
||||
import androidx.compose.foundation.layout.Column |
||||
import androidx.compose.material3.Text |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.ui.Modifier |
||||
import me.sample.library.MyLibraryIcon |
||||
import me.sample.library.MyLibraryText |
||||
import kmpresourcepublication.appmodule.generated.resources.* |
||||
import org.jetbrains.compose.resources.stringResource |
||||
|
||||
@Composable |
||||
fun App() { |
||||
Column { |
||||
val txt = "text: " |
||||
Text(txt + stringResource(Res.string.str_1)) |
||||
MyFeatureText(txt = txt) |
||||
MyLibraryText(txt = txt) |
||||
MyLibraryIcon(Modifier) |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
import androidx.compose.foundation.layout.Column |
||||
import androidx.compose.material3.Text |
||||
import androidx.compose.ui.Modifier |
||||
import androidx.compose.ui.platform.testTag |
||||
import androidx.compose.ui.test.ExperimentalTestApi |
||||
import androidx.compose.ui.test.assertTextEquals |
||||
import androidx.compose.ui.test.onNodeWithTag |
||||
import androidx.compose.ui.test.runComposeUiTest |
||||
import me.sample.app.App |
||||
import me.sample.app.MyFeatureText |
||||
import me.sample.library.MyLibraryText |
||||
import org.jetbrains.compose.resources.stringResource |
||||
import kmpresourcepublication.appmodule.generated.resources.* |
||||
import kotlin.test.Test |
||||
|
||||
@OptIn(ExperimentalTestApi::class) |
||||
class ComposeAppTest { |
||||
@Test |
||||
fun checkApp() = runComposeUiTest { |
||||
val txt = "test text: " |
||||
setContent { |
||||
Column { |
||||
App() |
||||
|
||||
Text( |
||||
modifier = Modifier.testTag("app-text"), |
||||
text = txt + stringResource(Res.string.str_1) |
||||
) |
||||
MyFeatureText(Modifier.testTag("feature-text"), txt) |
||||
MyLibraryText(Modifier.testTag("library-text"), txt) |
||||
} |
||||
} |
||||
|
||||
onNodeWithTag("app-text").assertTextEquals("test text: App text str_1") |
||||
onNodeWithTag("feature-text").assertTextEquals("test text: Feature text str_1") |
||||
onNodeWithTag("library-text").assertTextEquals("test text: Library text str_1") |
||||
} |
||||
} |
@ -1,3 +0,0 @@
|
||||
<resources> |
||||
<string name="str_1">NL Library text str_1</string> |
||||
</resources> |
@ -0,0 +1,46 @@
|
||||
plugins { |
||||
id("org.jetbrains.compose") |
||||
kotlin("multiplatform") |
||||
id("com.android.library") |
||||
} |
||||
|
||||
kotlin { |
||||
androidTarget() |
||||
jvm() |
||||
iosX64() |
||||
iosArm64() |
||||
iosSimulatorArm64() |
||||
js { browser() } |
||||
wasmJs { browser() } |
||||
|
||||
sourceSets { |
||||
all { |
||||
languageSettings { |
||||
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi") |
||||
} |
||||
} |
||||
commonMain.dependencies { |
||||
implementation(compose.runtime) |
||||
implementation(compose.material3) |
||||
implementation(compose.components.resources) |
||||
} |
||||
} |
||||
} |
||||
|
||||
android { |
||||
namespace = "me.sample.feature" |
||||
compileSdk = 34 |
||||
|
||||
defaultConfig { |
||||
minSdk = 24 |
||||
} |
||||
compileOptions { |
||||
sourceCompatibility = JavaVersion.VERSION_17 |
||||
targetCompatibility = JavaVersion.VERSION_17 |
||||
} |
||||
} |
||||
|
||||
compose { |
||||
kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("COMPOSE_COMPILER_PLUGIN_PLACEHOLDER")) |
||||
kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=KOTLIN_VERSION_PLACEHOLDER") |
||||
} |
@ -0,0 +1,3 @@
|
||||
<resources> |
||||
<string name="str_1">Feature text str_1</string> |
||||
</resources> |
@ -0,0 +1,12 @@
|
||||
package me.sample.app |
||||
|
||||
import androidx.compose.material3.Text |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.ui.Modifier |
||||
import org.jetbrains.compose.resources.stringResource |
||||
import kmpresourcepublication.featuremodule.generated.resources.* |
||||
|
||||
@Composable |
||||
fun MyFeatureText(modifier: Modifier = Modifier, txt: String) { |
||||
Text(txt + stringResource(Res.string.str_1), modifier) |
||||
} |
@ -1,27 +1,36 @@
|
||||
rootProject.name = "kmpResourcePublication" |
||||
include(":cmplib") |
||||
include(":featureModule") |
||||
//include(":appModule") |
||||
pluginManagement { |
||||
repositories { |
||||
gradlePluginPortal() |
||||
mavenCentral() |
||||
google() |
||||
mavenLocal() |
||||
//todo temporary repo for custom KGP plugin |
||||
maven("https://packages.jetbrains.team/files/p/mpp/kgp-for-compose2") |
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") |
||||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") |
||||
mavenLocal() |
||||
} |
||||
plugins { |
||||
id("org.jetbrains.kotlin.multiplatform").version("KOTLIN_VERSION_PLACEHOLDER") |
||||
id("org.jetbrains.compose").version("COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER") |
||||
id("com.android.library").version("AGP_VERSION_PLACEHOLDER") |
||||
id("com.android.application").version("AGP_VERSION_PLACEHOLDER") |
||||
} |
||||
} |
||||
dependencyResolutionManagement { |
||||
repositories { |
||||
mavenCentral() |
||||
google() |
||||
//todo temporary repo for custom KGP plugin |
||||
maven("https://packages.jetbrains.team/files/p/mpp/kgp-for-compose2") |
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") |
||||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") |
||||
mavenLocal() |
||||
maven { |
||||
url = uri(rootProject.projectDir.resolve("my-mvn")) |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue