diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt index 2e47c3946a..09360ae7e4 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt @@ -5,6 +5,7 @@ package org.jetbrains.compose.test.tests.integration +import org.gradle.util.GradleVersion import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.PreviewLogger import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.RemoteConnection import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.receiveConfigFromGradle @@ -213,6 +214,15 @@ class GradlePluginTest : GradlePluginTestBase() { } } + @Test + fun newAndroidTarget() { + Assumptions.assumeTrue(TestProperties.gradleBaseVersionForTests >= GradleVersion.version("8.0.0")) + with(testProject(TestProjects.newAndroidTarget)) { + gradle("build", "--dry-run").checks { + } + } + } + @Test fun jsMppIsNotBroken() = with( diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt index ac5b024917..a0cf78f314 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt @@ -87,7 +87,7 @@ class TestProject( private inline fun withGradleRunner(args: Array, runnerFn: GradleRunner.() -> BuildResult): BuildResult { if (testEnvironment.useGradleConfigurationCache) { - if (GradleVersion.version(TestProperties.gradleVersionForTests).baseVersion < GradleVersion.version("8.0")) { + if (TestProperties.gradleBaseVersionForTests < GradleVersion.version("8.0")) { // Gradle 7.* does not use the configuration cache in the same build. // In other words, if cache misses, Gradle performs configuration, // but does not, use the serialized task graph. @@ -166,5 +166,4 @@ class TestProject( } } } -} - +} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt index b2a84f49ba..b23fccb0b9 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt @@ -8,6 +8,7 @@ package org.jetbrains.compose.test.utils object TestProjects { const val jvm = "application/jvm" const val mpp = "application/mpp" + const val newAndroidTarget = "application/newAndroidTarget" const val proguard = "application/proguard" const val customCompiler = "application/custom-compiler" const val customCompilerArgs = "application/custom-compiler-args" diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt index eb5bd4b85b..d7bb578b51 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt @@ -5,8 +5,11 @@ package org.jetbrains.compose.test.utils +import org.gradle.util.GradleVersion import java.io.File +private const val COMPOSE_TESTS_GRADLE_VERSION_PROPERTY = "compose.tests.gradle.version" + object TestProperties { val composeCompilerVersion: String get() = notNullSystemProperty("compose.tests.compiler.version") @@ -20,8 +23,12 @@ object TestProperties { val composeGradlePluginVersion: String get() = notNullSystemProperty("compose.tests.compose.gradle.plugin.version") - val gradleVersionForTests: String? - get() = System.getProperty("compose.tests.gradle.version") + val gradleVersionForTests: String + get() = System.getProperty(COMPOSE_TESTS_GRADLE_VERSION_PROPERTY) + ?: error("System property '$COMPOSE_TESTS_GRADLE_VERSION_PROPERTY' is not set") + + val gradleBaseVersionForTests: GradleVersion + get() = GradleVersion.version(gradleVersionForTests).baseVersion val gradleConfigurationCache: Boolean get() = System.getProperty("compose.tests.gradle.configuration.cache") == "true" diff --git a/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/build.gradle b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/build.gradle new file mode 100644 index 0000000000..b99bd02d22 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/build.gradle @@ -0,0 +1,34 @@ +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "com.android.kotlin.multiplatform.library" + id "org.jetbrains.compose" +} + +repositories { + jetbrainsCompose() + google() +} + +kotlin { + targetHierarchy.default() + + androidLibrary { + namespace = "com.google.samples.apps.diceroller.shared" + compileSdk = 34 + } + + jvm() + + sourceSets { + getByName("commonMain") { + dependencies { + implementation(compose.ui) + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material3) + } + } + } +} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/gradle.properties b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/gradle.properties new file mode 100644 index 0000000000..3544b854f8 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/gradle.properties @@ -0,0 +1 @@ +android.useAndroidX = true \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/settings.gradle new file mode 100644 index 0000000000..0b59b8314d --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + plugins { + id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' + id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' + id 'com.android.kotlin.multiplatform.library' version '8.2.0-alpha13' + } + repositories { + mavenLocal() + gradlePluginPortal() + google() + } +} +rootProject.name = "mpp" \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/src/commonMain/kotlin/AppView.kt b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/src/commonMain/kotlin/AppView.kt new file mode 100644 index 0000000000..79a1f141d9 --- /dev/null +++ b/gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/src/commonMain/kotlin/AppView.kt @@ -0,0 +1,17 @@ +import androidx.compose.material.Text +import androidx.compose.material.Button +import androidx.compose.material.MaterialTheme +import androidx.compose.runtime.* + +@Composable +fun AppView() { + var text by remember { mutableStateOf("Hello, World!") } + + MaterialTheme { + Button(onClick = { + text = "Hello, Multiplatform!" + }) { + Text(text) + } + } +} \ No newline at end of file