From 8f3578bdcaa9941d2a755861747a0f6612d6aff2 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com> Date: Mon, 6 Feb 2023 22:25:24 +0300 Subject: [PATCH] Fix gradle tests (#2708) * Add docker file for Gradle tests on TeamCity * Remove configuring JDK for tests * Update compose & kotlin compiler in testAndroidxCompiler --- ci/docker/gradle-plugin-tests/Dockerfile | 11 +++++++++++ .../buildSrc/src/main/kotlin/gradleUtils.kt | 7 ------- gradle-plugins/compose/build.gradle.kts | 4 ++-- .../test/tests/integration/DesktopApplicationTest.kt | 4 ++-- gradle-plugins/preview-rpc/build.gradle.kts | 2 -- 5 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 ci/docker/gradle-plugin-tests/Dockerfile diff --git a/ci/docker/gradle-plugin-tests/Dockerfile b/ci/docker/gradle-plugin-tests/Dockerfile new file mode 100644 index 0000000000..a900ac44c0 --- /dev/null +++ b/ci/docker/gradle-plugin-tests/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:20.04 + +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update -y && \ + apt-get install binutils --no-install-recommends -y && \ + apt-get install fakeroot --no-install-recommends -y && \ + apt-get install dpkg --no-install-recommends -y && \ + apt-get install dpkg-dev --no-install-recommends -y && \ + apt-get install libgl-dev --no-install-recommends -y +ENV PATH="/usr/lib/x86_64-linux-gnu/:$PATH" +RUN apt-get install openjdk-16-jdk --no-install-recommends -y diff --git a/gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt b/gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt index b88ccc1939..99c27ccee9 100644 --- a/gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt +++ b/gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt @@ -28,13 +28,6 @@ inline fun Project.configureIfExists(fn: T.() -> Unit) { val isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows -fun Test.configureJavaForComposeTest() { - val toolchains = project.extensions.getByName("javaToolchains") as JavaToolchainService - javaLauncher.set(toolchains.launcherFor { - languageVersion.set(JavaLanguageVersion.of(16)) - }) -} - fun Project.configureAllTests(fn: Test.() -> Unit = {}) { fun DependencyHandler.testImplementation(notation: Any) = add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, notation) diff --git a/gradle-plugins/compose/build.gradle.kts b/gradle-plugins/compose/build.gradle.kts index 52a88fd13e..9e1620d747 100644 --- a/gradle-plugins/compose/build.gradle.kts +++ b/gradle-plugins/compose/build.gradle.kts @@ -118,8 +118,9 @@ tasks.test { * Thus, the only option is to download the necessary JDK distributions ourselves. */ val jdkVersionsForTests = listOf(11, 15, 18, 19) -val jdkForTestsRoot = project.rootProject.layout.buildDirectory.dir("jdks").get().asFile +val jdkForTestsRoot = project.gradle.gradleUserHomeDir.resolve("compose-jb-jdks") val downloadJdksForTests = tasks.register("downloadJdksForTests") {} + for (jdkVersion in jdkVersionsForTests) { val ext = if (hostOS == OS.Windows) ".zip" else ".tar.gz" val archive = jdkForTestsRoot.resolve("$jdkVersion$ext") @@ -161,7 +162,6 @@ for (gradleVersion in supportedGradleVersions) { } configureAllTests { - configureJavaForComposeTest() dependsOn(":publishToMavenLocal") systemProperty("compose.tests.compose.gradle.plugin.version", BuildProperties.deployVersion(project)) val summaryDir = project.buildDir.resolve("test-summary") diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt index 54dcd83074..a65c398452 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt @@ -69,8 +69,8 @@ class DesktopApplicationTest : GradlePluginTestBase() { @Test fun testAndroidxCompiler() = testProject( TestProjects.customCompiler, defaultTestEnvironment.copy( - kotlinVersion = "1.6.10", - composeCompilerPlugin = "\"androidx.compose.compiler:compiler:1.1.1\"" + kotlinVersion = "1.8.0", + composeCompilerPlugin = "\"androidx.compose.compiler:compiler:1.4.0\"" ) ).checkCustomComposeCompiler() diff --git a/gradle-plugins/preview-rpc/build.gradle.kts b/gradle-plugins/preview-rpc/build.gradle.kts index bea6f46c06..5e0c8b055a 100644 --- a/gradle-plugins/preview-rpc/build.gradle.kts +++ b/gradle-plugins/preview-rpc/build.gradle.kts @@ -26,8 +26,6 @@ val serializeClasspath by tasks.registering(SerializeClasspathTask::class) { } tasks.test.configure { - configureJavaForComposeTest() - dependsOn(serializeClasspath) systemProperty( "org.jetbrains.compose.tests.rpc.classpath.file",