diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt index 4b2159648f..fe84b26b32 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/tasks/AbstractConfigureDesktopPreviewTask.kt @@ -37,12 +37,12 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask( project.providers.gradleProperty("compose.desktop.preview.ide.port") @get:InputFiles - internal val uiTooling = project.configurations.detachedConfiguration( + internal val uiTooling: FileCollection = project.configurations.detachedConfiguration( project.dependencies.create("org.jetbrains.compose.ui:ui-tooling-desktop:${ComposeBuildConfig.composeVersion}") ).apply { isTransitive = false } @get:InputFiles - internal val hostClasspath = project.configurations.detachedConfiguration( + internal val hostClasspath: FileCollection = project.configurations.detachedConfiguration( project.dependencies.create("org.jetbrains.compose:preview-rpc:${ComposeBuildConfig.composeVersion}") ) 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 98cf5e7949..5e392275ad 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 @@ -36,7 +36,12 @@ class GradlePluginTest : GradlePluginTestBase() { } @Test - fun configurePreview() { + fun configurePreviewWithoutConfigurationCache() = configurePreview(withConfigurationCache = false) + + @Test + fun configurePreviewWithConfigurationCache() = configurePreview(withConfigurationCache = true) + + private fun configurePreview(withConfigurationCache: Boolean) { val isAlive = AtomicBoolean(true) val receivedConfigCount = AtomicInteger(0) val port = AtomicInteger(-1) @@ -45,7 +50,7 @@ class GradlePluginTest : GradlePluginTestBase() { soTimeout = 10_000 } port.set(serverSocket.localPort) - try { + serverSocket.use { while (isAlive.get()) { try { val socket = serverSocket.accept() @@ -63,9 +68,6 @@ class GradlePluginTest : GradlePluginTestBase() { } } } - - } finally { - serverSocket.close() } } @@ -80,7 +82,7 @@ class GradlePluginTest : GradlePluginTestBase() { } try { - testConfigureDesktopPreivewImpl(port.get()) + testConfigureDesktopPreviewImpl(port.get(), withConfigurationCache) } finally { isAlive.set(false) connectionThread.interrupt() @@ -94,20 +96,31 @@ class GradlePluginTest : GradlePluginTestBase() { } } - private fun testConfigureDesktopPreivewImpl(port: Int) { + private fun testConfigureDesktopPreviewImpl(port: Int, withConfigurationCache: Boolean) { check(port > 0) { "Invalid port: $port" } with(testProject(TestProjects.jvmPreview)) { val portProperty = "-Pcompose.desktop.preview.ide.port=$port" val previewTargetProperty = "-Pcompose.desktop.preview.target=PreviewKt.ExamplePreview" val jvmTask = ":jvm:configureDesktopPreview" - gradle(jvmTask, portProperty, previewTargetProperty) + val configurationCacheArg = "--configuration-cache" + val jvmRunner = if (withConfigurationCache) { + gradle(jvmTask, portProperty, previewTargetProperty, configurationCacheArg) + } else { + gradle(jvmTask, portProperty, previewTargetProperty) + } + jvmRunner .build() .checks { check -> check.taskOutcome(jvmTask, TaskOutcome.SUCCESS) } val mppTask = ":mpp:configureDesktopPreviewDesktop" - gradle(mppTask, portProperty, previewTargetProperty) + val mppRunner = if (withConfigurationCache) { + gradle(mppTask, portProperty, previewTargetProperty, configurationCacheArg) + } else { + gradle(mppTask, portProperty, previewTargetProperty) + } + mppRunner .build() .checks { check -> check.taskOutcome(mppTask, TaskOutcome.SUCCESS) diff --git a/gradle-plugins/gradle/wrapper/gradle-wrapper.properties b/gradle-plugins/gradle/wrapper/gradle-wrapper.properties index 2e6e5897b5..ae04661ee7 100644 --- a/gradle-plugins/gradle/wrapper/gradle-wrapper.properties +++ b/gradle-plugins/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists