Browse Source

Add test for new android target (#3624)

pull/3628/head
Alexey Tsvetkov 1 year ago committed by GitHub
parent
commit
f81f6fa88c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt
  2. 3
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt
  3. 1
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt
  4. 11
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt
  5. 34
      gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/build.gradle
  6. 1
      gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/gradle.properties
  7. 13
      gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/settings.gradle
  8. 17
      gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/src/commonMain/kotlin/AppView.kt

10
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 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.PreviewLogger
import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.RemoteConnection import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.RemoteConnection
import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.receiveConfigFromGradle 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 @Test
fun jsMppIsNotBroken() = fun jsMppIsNotBroken() =
with( with(

3
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<out String>, runnerFn: GradleRunner.() -> BuildResult): BuildResult { private inline fun withGradleRunner(args: Array<out String>, runnerFn: GradleRunner.() -> BuildResult): BuildResult {
if (testEnvironment.useGradleConfigurationCache) { 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. // Gradle 7.* does not use the configuration cache in the same build.
// In other words, if cache misses, Gradle performs configuration, // In other words, if cache misses, Gradle performs configuration,
// but does not, use the serialized task graph. // but does not, use the serialized task graph.
@ -167,4 +167,3 @@ class TestProject(
} }
} }
} }

1
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 { object TestProjects {
const val jvm = "application/jvm" const val jvm = "application/jvm"
const val mpp = "application/mpp" const val mpp = "application/mpp"
const val newAndroidTarget = "application/newAndroidTarget"
const val proguard = "application/proguard" const val proguard = "application/proguard"
const val customCompiler = "application/custom-compiler" const val customCompiler = "application/custom-compiler"
const val customCompilerArgs = "application/custom-compiler-args" const val customCompilerArgs = "application/custom-compiler-args"

11
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt

@ -5,8 +5,11 @@
package org.jetbrains.compose.test.utils package org.jetbrains.compose.test.utils
import org.gradle.util.GradleVersion
import java.io.File import java.io.File
private const val COMPOSE_TESTS_GRADLE_VERSION_PROPERTY = "compose.tests.gradle.version"
object TestProperties { object TestProperties {
val composeCompilerVersion: String val composeCompilerVersion: String
get() = notNullSystemProperty("compose.tests.compiler.version") get() = notNullSystemProperty("compose.tests.compiler.version")
@ -20,8 +23,12 @@ object TestProperties {
val composeGradlePluginVersion: String val composeGradlePluginVersion: String
get() = notNullSystemProperty("compose.tests.compose.gradle.plugin.version") get() = notNullSystemProperty("compose.tests.compose.gradle.plugin.version")
val gradleVersionForTests: String? val gradleVersionForTests: String
get() = System.getProperty("compose.tests.gradle.version") 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 val gradleConfigurationCache: Boolean
get() = System.getProperty("compose.tests.gradle.configuration.cache") == "true" get() = System.getProperty("compose.tests.gradle.configuration.cache") == "true"

34
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)
}
}
}
}

1
gradle-plugins/compose/src/test/test-projects/application/newAndroidTarget/gradle.properties

@ -0,0 +1 @@
android.useAndroidX = true

13
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"

17
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)
}
}
}
Loading…
Cancel
Save