Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private fun Project.configureGeneratedAndroidComponentAssets(
)
tasks.configureEach { task ->
//fix agp task dependencies for AndroidStudio preview
if (task.name == "compile${camelComponentName}Sources") {
if (task.name == "package${camelComponentName}Resources") {
task.dependsOn(copyComponentAssets)
}
//fix linter task dependencies for `build` task
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.jetbrains.compose.test.tests.integration

import org.gradle.util.GradleVersion
import org.jetbrains.compose.desktop.application.internal.ComposeProperties
import org.jetbrains.compose.internal.Version
import org.jetbrains.compose.internal.utils.Arch
import org.jetbrains.compose.internal.utils.OS
import org.jetbrains.compose.internal.utils.currentArch
Expand Down Expand Up @@ -342,6 +344,28 @@ class ResourcesTest : GradlePluginTestBase() {
}
}

@Test
fun testAndroidPreviewCallsResourcesPackaging() {
// Valid for AGP < 9.0.0 only
// https://youtrack.jetbrains.com/issue/CMP-7170
Assumptions.assumeTrue { Version.fromString(defaultTestEnvironment.agpVersion).major < 9 }
with(testProject("misc/oldAndroidTargetAppWithResources", defaultTestEnvironment)) {
//AndroidStudio previews call `compileDebugSources` task
gradle(":appModule:compileDebugSources").checks {
check.taskSuccessful(":appModule:packageDebugResources")
check.taskSuccessful(":featureModule:packageDebugResources")
check.taskSuccessful(":featureModule:copyDebugComposeResourcesToAndroidAssets")

val resourceFile = "composeResources/oldagpresources.featuremodule.generated.resources/values/strings.commonMain.cvr"
assertTrue {
file(
"featureModule/build/generated/assets/copyDebugComposeResourcesToAndroidAssets/$resourceFile"
).exists()
}
}
}
}

@Test
fun testDisableMultimoduleResources() {
with(testProject("misc/commonResources")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id("org.jetbrains.compose")
kotlin("plugin.compose")
id("com.android.application")
}

android {
namespace = "me.sample.app"
compileSdk = 35
defaultConfig {
applicationId = "org.example.project"
minSdk = 23
targetSdk = 35
versionCode = 1
versionName = "1.0"
}
}

dependencies {
implementation(project(":featureModule"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<application/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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 oldagpresources.featuremodule.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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id("org.jetbrains.compose").apply(false)
kotlin("multiplatform").apply(false)
kotlin("plugin.compose").apply(false)
id("com.android.library").apply(false)
id("com.android.application").apply(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id("org.jetbrains.compose")
kotlin("multiplatform")
kotlin("plugin.compose")
id("com.android.library")
}

kotlin {
jvm()

androidTarget()

sourceSets {
commonMain.dependencies {
api(compose.runtime)
api(compose.material3)
api(compose.components.resources)
}
}
}
android {
namespace = "me.sample.feature"
compileSdk = 35
}

compose.resources {
publicResClass = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="str_1">Feature text str_1</string>
</resources>
Original file line number Diff line number Diff line change
@@ -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 oldagpresources.featuremodule.generated.resources.*

@Composable
fun MyFeatureText(modifier: Modifier = Modifier, txt: String) {
Text(txt + stringResource(Res.string.str_1), modifier)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
kotlin.code.style=official
android.useAndroidX=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
rootProject.name = "oldAgpResources"
include(":featureModule")
include(":appModule")
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
mavenCentral()
google()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
}
plugins {
id("org.jetbrains.kotlin.multiplatform").version("KOTLIN_VERSION_PLACEHOLDER")
id("org.jetbrains.kotlin.plugin.compose").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()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
mavenLocal()
}
}
Loading