From 3483feef2a9e5ff0d19c8315d7f67545026f497a Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov <654232+AlexeyTsvetkov@users.noreply.github.com> Date: Tue, 4 Apr 2023 14:18:27 +0300 Subject: [PATCH] Unzip wix to build directory (#2838) Resolves #2804 --- .../desktop/application/internal/wixToolset.kt | 5 +++-- .../tests/integration/DesktopApplicationTest.kt | 15 +++++++++++++++ .../org/jetbrains/compose/test/utils/fileUtils.kt | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt index 5180646cb5..a2d48bba4c 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/wixToolset.kt @@ -11,6 +11,7 @@ import org.gradle.api.tasks.Copy import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask import org.jetbrains.compose.internal.utils.OS import org.jetbrains.compose.internal.utils.currentOS +import org.jetbrains.compose.internal.utils.ioFile import java.io.File internal const val DOWNLOAD_WIX_TOOLSET_TASK_NAME = "downloadWix" @@ -37,7 +38,7 @@ internal fun JvmApplicationContext.configureWix() { val wixDir = project.gradle.gradleUserHomeDir.resolve("compose-jb") val fileName = "wix311" val zipFile = wixDir.resolve("$fileName.zip") - val unzipDir = root.projectDir.resolve(fileName) + val unzipDir = root.layout.buildDirectory.dir(fileName) val download = root.tasks.maybeCreate(DOWNLOAD_WIX_TOOLSET_TASK_NAME, Download::class.java).apply { onlyIf { !zipFile.isFile } src("https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip") @@ -46,7 +47,7 @@ internal fun JvmApplicationContext.configureWix() { val unzip = root.tasks.maybeCreate(UNZIP_WIX_TOOLSET_TASK_NAME, Copy::class.java).apply { dependsOn(download) from(project.zipTree(zipFile)) - destinationDir = unzipDir + destinationDir = unzipDir.ioFile } project.eachWindowsPackageTask { dependsOn(unzip) 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 fb25d164d6..6ae1fe94eb 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 @@ -503,4 +503,19 @@ class DesktopApplicationTest : GradlePluginTestBase() { check.taskSuccessful(":runDistributable") } } + + @Test + fun testWixUnzip() { + Assumptions.assumeTrue(currentOS == OS.Windows) { "The test is only relevant for Windows" } + + with(testProject(TestProjects.jvm)) { + gradle(":unzipWix").checks { + check.taskSuccessful(":unzipWix") + + file("build/wix311").checkExists() + file("build/wix311/light.exe").checkExists() + file("wix311").checkNotExists() + } + } + } } diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt index dc94686621..cf320c0c12 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt @@ -25,4 +25,8 @@ fun File.checkExists(): File = apply { } } } +} + +fun File.checkNotExists(): File = apply { + check(!exists()) { "File must not exist: $absolutePath" } } \ No newline at end of file