From 927ccf2ab1e5275bd6f91ec5050eafd7a822ee57 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Wed, 25 Mar 2020 02:50:20 +0300 Subject: [PATCH] Wizard: fix 192 tests --- .../AbstractNewWizardProjectImportTest.kt | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/AbstractNewWizardProjectImportTest.kt b/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/AbstractNewWizardProjectImportTest.kt index c74ae11a5c9..15725f5935b 100644 --- a/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/AbstractNewWizardProjectImportTest.kt +++ b/idea/idea-new-project-wizard/tests/org/jetbrains/kotlin/tools/projectWizard/wizard/AbstractNewWizardProjectImportTest.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.tools.projectWizard.wizard +import com.intellij.openapi.application.impl.ApplicationInfoImpl import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil import com.intellij.openapi.projectRoots.ProjectJdkTable import com.intellij.openapi.projectRoots.SimpleJavaSdkType @@ -79,23 +80,29 @@ abstract class AbstractNewWizardProjectImportTest : PlatformTestCase() { } private fun prepareGradleBuildSystem(directory: Path) { - project.getService(GradleSettings::class.java)?.apply { - gradleVmOptions = GradleEnvironment.Headless.GRADLE_VM_OPTIONS ?: gradleVmOptions + com.intellij.openapi.components.ServiceManager.getService(project, GradleSettings::class.java)?.apply { isOfflineWork = GradleEnvironment.Headless.GRADLE_OFFLINE?.toBoolean() ?: isOfflineWork serviceDirectoryPath = GradleEnvironment.Headless.GRADLE_SERVICE_DIRECTORY ?: serviceDirectoryPath storeProjectFilesExternally = true } - val settings = GradleProjectSettings().apply { - externalProjectPath = directory.toString() - isUseAutoImport = false - isUseQualifiedModuleNames = true - gradleJvm = SDK_NAME - distributionType = DistributionType.WRAPPED + // not needed on <= 192 (and causes error on <= 192 ): + if (!is192orLess()) { + val settings = GradleProjectSettings().apply { + externalProjectPath = directory.toString() + isUseAutoImport = false + isUseQualifiedModuleNames = true + gradleJvm = SDK_NAME + distributionType = DistributionType.WRAPPED + } + ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID).linkProject(settings) } - ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID).linkProject(settings) } + private fun is192orLess() = + ApplicationInfoImpl.getShadowInstance().minorVersionMainPart.toIntOrNull()?.let { it <= 2 } == true + && ApplicationInfoImpl.getShadowInstance().majorVersion == "2019" + companion object { private const val SDK_NAME = "defaultSdk"