Move tests from GradleImportingTestCase to MultiplePluginVersionGradleImportingTestCase

This commit is contained in:
Alexander Dudinsky
2021-02-12 15:55:58 +03:00
parent e96f64e6c9
commit 2c29957cb8
57 changed files with 232 additions and 670 deletions
@@ -19,10 +19,10 @@ import org.jetbrains.kotlin.idea.util.projectStructure.allModules
import org.jetbrains.kotlin.konan.library.konanCommonLibraryPath import org.jetbrains.kotlin.konan.library.konanCommonLibraryPath
import org.jetbrains.kotlin.konan.library.konanPlatformLibraryPath import org.jetbrains.kotlin.konan.library.konanPlatformLibraryPath
import org.jetbrains.kotlin.platform.konan.isNative import org.jetbrains.kotlin.platform.konan.isNative
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.jetbrains.plugins.gradle.util.GradleConstants import org.jetbrains.plugins.gradle.util.GradleConstants
import org.junit.Assert.* import org.junit.Assert.*
import org.junit.Test import org.junit.Test
import org.junit.runners.Parameterized
import java.io.File import java.io.File
@@ -30,6 +30,7 @@ class GradleNativeLibrariesInIDENamingTest : TestCaseWithFakeKotlinNative() {
// Test naming of Kotlin/Native libraries // Test naming of Kotlin/Native libraries
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testLibrariesNaming() { fun testLibrariesNaming() {
configureProject() configureProject()
importProject() importProject()
@@ -40,13 +41,6 @@ class GradleNativeLibrariesInIDENamingTest : TestCaseWithFakeKotlinNative() {
override fun getExternalSystemConfigFileName() = GradleConstants.KOTLIN_DSL_SCRIPT_NAME override fun getExternalSystemConfigFileName() = GradleConstants.KOTLIN_DSL_SCRIPT_NAME
override fun testDataDirName() = "nativeLibraries" override fun testDataDirName() = "nativeLibraries"
companion object {
@Parameterized.Parameters(name = "{index}: with Gradle-{0}")
@Throws(Throwable::class)
@JvmStatic
fun data() = listOf(arrayOf("4.10.2"))
}
} }
private val NATIVE_LIBRARY_NAME_REGEX = Regex("^Kotlin/Native ([\\d\\w\\.-]+) - ([\\w\\d]+)( \\[([\\w\\d_]+)\\])?$") private val NATIVE_LIBRARY_NAME_REGEX = Regex("^Kotlin/Native ([\\d\\w\\.-]+) - ([\\w\\d]+)( \\[([\\w\\d_]+)\\])?$")
@@ -9,9 +9,9 @@ import com.intellij.openapi.roots.DependencyScope
import org.jetbrains.kotlin.gradle.ModuleInfo import org.jetbrains.kotlin.gradle.ModuleInfo
import org.jetbrains.kotlin.gradle.checkProjectStructure import org.jetbrains.kotlin.gradle.checkProjectStructure
import org.jetbrains.kotlin.idea.configuration.externalCompilerVersion import org.jetbrains.kotlin.idea.configuration.externalCompilerVersion
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.jetbrains.plugins.gradle.util.GradleConstants import org.jetbrains.plugins.gradle.util.GradleConstants
import org.junit.Test import org.junit.Test
import org.junit.runners.Parameterized
class GradleNativeLibrariesPropagationTest : TestCaseWithFakeKotlinNative() { class GradleNativeLibrariesPropagationTest : TestCaseWithFakeKotlinNative() {
@@ -22,6 +22,7 @@ class GradleNativeLibrariesPropagationTest : TestCaseWithFakeKotlinNative() {
private val testedTargets = setOf("ios_arm64", "ios_x64", "watchos_arm32", "watchos_x86") private val testedTargets = setOf("ios_arm64", "ios_x64", "watchos_arm32", "watchos_x86")
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testCommonIOS() { fun testCommonIOS() {
configureProject() configureProject()
importProject() importProject()
@@ -63,6 +64,7 @@ class GradleNativeLibrariesPropagationTest : TestCaseWithFakeKotlinNative() {
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "<1.4.0", skipForMaster = true)
fun testCommonIOSWithDisabledPropagation() { fun testCommonIOSWithDisabledPropagation() {
configureProject() configureProject()
importProject() importProject()
@@ -110,11 +112,4 @@ class GradleNativeLibrariesPropagationTest : TestCaseWithFakeKotlinNative() {
libraryDependency("Kotlin/Native $kotlinVersion - $libraryName [$target]", DependencyScope.PROVIDED) libraryDependency("Kotlin/Native $kotlinVersion - $libraryName [$target]", DependencyScope.PROVIDED)
noPlatformLibrary(libraryName, testedTargets - target) noPlatformLibrary(libraryName, testedTargets - target)
} }
companion object {
@Parameterized.Parameters(name = "{index}: with Gradle-{0}")
@Throws(Throwable::class)
@JvmStatic
fun data() = listOf(arrayOf("4.10.2"))
}
} }
@@ -5,10 +5,10 @@
package org.jetbrains.kotlin.ide.konan.gradle package org.jetbrains.kotlin.ide.konan.gradle
import org.jetbrains.kotlin.idea.codeInsight.gradle.GradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import java.io.File import java.io.File
abstract class TestCaseWithFakeKotlinNative : GradleImportingTestCase() { abstract class TestCaseWithFakeKotlinNative : MultiplePluginVersionGradleImportingTestCase() {
protected fun configureProject() { protected fun configureProject() {
configureByFiles() configureByFiles()
@@ -27,7 +27,6 @@ import com.intellij.testFramework.VfsTestUtil
import com.intellij.testFramework.runInEdtAndWait import com.intellij.testFramework.runInEdtAndWait
import junit.framework.TestCase import junit.framework.TestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.mppImportTestMinVersionForMaster
import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TagsTestDataUtil import org.jetbrains.kotlin.test.TagsTestDataUtil
import org.jetbrains.kotlin.test.TagsTestDataUtil.TagInfo import org.jetbrains.kotlin.test.TagsTestDataUtil.TagInfo
@@ -39,13 +38,13 @@ import java.io.File
class GradleMultiplatformHighlightingTest : MultiplePluginVersionGradleImportingTestCase() { class GradleMultiplatformHighlightingTest : MultiplePluginVersionGradleImportingTestCase() {
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testFirst() { fun testFirst() {
doTest() doTest()
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testNoErrors() { fun testNoErrors() {
doTest() doTest()
} }
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.config.SourceKotlinRootType
import org.jetbrains.kotlin.config.TestResourceKotlinRootType import org.jetbrains.kotlin.config.TestResourceKotlinRootType
import org.jetbrains.kotlin.config.TestSourceKotlinRootType import org.jetbrains.kotlin.config.TestSourceKotlinRootType
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.mppImportTestMinVersionForMaster
import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.platform.js.JsPlatforms import org.jetbrains.kotlin.platform.js.JsPlatforms
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
@@ -41,7 +40,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testImportHMPPFlag() { fun testImportHMPPFlag() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -56,7 +55,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testImportIntermediateModules() { fun testImportIntermediateModules() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -232,7 +231,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testJvmWithJavaOnHMPP() { fun testJvmWithJavaOnHMPP() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -344,7 +343,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testPrecisePlatformsHmpp() { fun testPrecisePlatformsHmpp() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -378,7 +377,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testPrecisePlatformsWithUnrelatedModuleHmpp() { fun testPrecisePlatformsWithUnrelatedModuleHmpp() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -426,7 +425,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testOrphanSourceSet() { fun testOrphanSourceSet() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -451,7 +450,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testSourceSetIncludedIntoCompilationDirectly() { fun testSourceSetIncludedIntoCompilationDirectly() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -476,7 +475,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testDefaultSourceSetDependsOnDefaultSourceSet() { fun testDefaultSourceSetDependsOnDefaultSourceSet() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -505,7 +504,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testDefaultSourceSetIncludedIntoAnotherCompilationDirectly() { fun testDefaultSourceSetIncludedIntoAnotherCompilationDirectly() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -525,7 +524,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testSourceSetsWithDependsOnButNotIncludedIntoCompilation() { fun testSourceSetsWithDependsOnButNotIncludedIntoCompilation() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -560,7 +559,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testCustomAddToCompilationPlusDependsOn() { fun testCustomAddToCompilationPlusDependsOn() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -579,7 +578,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testCommonMainIsSingleBackend() { fun testCommonMainIsSingleBackend() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -619,12 +618,9 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
override fun importProject() { override fun importProject() {
val isUseQualifiedModuleNames = currentExternalProjectSettings.isUseQualifiedModuleNames val isUseQualifiedModuleNames = currentExternalProjectSettings.isUseQualifiedModuleNames
currentExternalProjectSettings.isUseQualifiedModuleNames = true currentExternalProjectSettings.isUseQualifiedModuleNames = true
val isCreateEmptyContentRootDirectories = currentExternalProjectSettings.isCreateEmptyContentRootDirectories
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = true
try { try {
super.importProject() super.importProject(true)
} finally { } finally {
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = isCreateEmptyContentRootDirectories
currentExternalProjectSettings.isUseQualifiedModuleNames = isUseQualifiedModuleNames currentExternalProjectSettings.isUseQualifiedModuleNames = isUseQualifiedModuleNames
} }
} }
@@ -10,7 +10,6 @@ import com.intellij.psi.*
import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTreeUtil
import com.intellij.testFramework.runInEdtAndGet import com.intellij.testFramework.runInEdtAndGet
import org.jetbrains.kotlin.idea.codeInsight.gradle.MasterPluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MasterPluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.mppImportTestMinVersionForMaster
import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.jetbrains.kotlin.idea.core.util.toPsiFile
import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.psi.KtTreeVisitorVoid import org.jetbrains.kotlin.psi.KtTreeVisitorVoid
@@ -21,7 +20,7 @@ import org.junit.Test
class ImportAndCheckNavigation : MasterPluginVersionGradleImportingTestCase() { class ImportAndCheckNavigation : MasterPluginVersionGradleImportingTestCase() {
@Test @Test
@PluginTargetVersions(gradleVersion = "6.0+", pluginVersion = "1.4+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(gradleVersion = "6.0+", pluginVersion = "1.4+")
fun testNavigationToCommonizedLibrary() { fun testNavigationToCommonizedLibrary() {
val files = configureAndImportProject() val files = configureAndImportProject()
@@ -9,7 +9,6 @@ import com.intellij.openapi.roots.DependencyScope
import org.jetbrains.jps.model.java.JavaResourceRootType import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.jps.model.java.JavaSourceRootType import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.legacyMppImportTestMinVersionForMaster
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
@@ -27,7 +26,7 @@ class KaptImportingTest : MultiplePluginVersionGradleImportingTestCase() {
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testModulePerSourceSet() { fun testModulePerSourceSet() {
// Disable testing import module per source set test in Android Studio as this mode is not supported in Android Studio // Disable testing import module per source set test in Android Studio as this mode is not supported in Android Studio
if (isAndroidStudio()) { if (isAndroidStudio()) {
@@ -60,7 +59,7 @@ class KaptImportingTest : MultiplePluginVersionGradleImportingTestCase() {
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testModulePerSourceSetDisabled() { fun testModulePerSourceSetDisabled() {
configureByFiles() configureByFiles()
importProject(false) importProject(false)
@@ -25,7 +25,6 @@ import com.intellij.util.PathUtil
import junit.framework.TestCase import junit.framework.TestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.facetSettings import org.jetbrains.kotlin.idea.codeInsight.gradle.facetSettings
import org.jetbrains.kotlin.idea.codeInsight.gradle.legacyMppImportTestMinVersionForMaster
import org.jetbrains.kotlin.idea.facet.KotlinFacet import org.jetbrains.kotlin.idea.facet.KotlinFacet
import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.idea.util.rootManager import org.jetbrains.kotlin.idea.util.rootManager
@@ -58,7 +57,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testPlatformToCommonDependency() { fun testPlatformToCommonDependency() {
val files = configureByFiles() val files = configureByFiles()
importProject() importProject()
@@ -79,7 +78,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testPlatformToCommonExpectedByDependency() { fun testPlatformToCommonExpectedByDependency() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -94,7 +93,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testPlatformToCommonDependencyRoot() { fun testPlatformToCommonDependencyRoot() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -105,7 +104,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testMultiProject() { fun testMultiProject() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -120,7 +119,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testDependenciesReachableViaImpl() { fun testDependenciesReachableViaImpl() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -137,7 +136,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testTransitiveImplement() { fun testTransitiveImplement() {
configureByFiles() configureByFiles()
@@ -186,7 +185,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testTransitiveImplementWithNonDefaultConfig() { fun testTransitiveImplementWithNonDefaultConfig() {
configureByFiles() configureByFiles()
@@ -231,7 +230,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testTransitiveImplementWithAndroid() { fun testTransitiveImplementWithAndroid() {
configureByFiles() configureByFiles()
@@ -262,7 +261,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun simpleAndroidAppWithCommonModule() { fun simpleAndroidAppWithCommonModule() {
configureByFiles() configureByFiles()
@@ -291,7 +290,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testJsTestOutputFile() { fun testJsTestOutputFile() {
configureByFiles() configureByFiles()
@@ -308,7 +307,7 @@ class MultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTe
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testJsProductionOutputFile() { fun testJsProductionOutputFile() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -10,7 +10,6 @@ import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.roots.* import com.intellij.openapi.roots.*
import com.intellij.openapi.roots.impl.ModulesOrderEnumerator import com.intellij.openapi.roots.impl.ModulesOrderEnumerator
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.mppImportTestMinVersionForMaster
import org.jetbrains.kotlin.idea.util.sourceRoots import org.jetbrains.kotlin.idea.util.sourceRoots
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
@@ -19,7 +18,7 @@ import java.io.File
class NewMultiplatformKaptProjectImportingTest : MultiplePluginVersionGradleImportingTestCase() { class NewMultiplatformKaptProjectImportingTest : MultiplePluginVersionGradleImportingTestCase() {
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.40+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.40+")
fun testKaptPaths() { fun testKaptPaths() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -72,7 +71,7 @@ class NewMultiplatformKaptProjectImportingTest : MultiplePluginVersionGradleImpo
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.40+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.40+")
fun testRuntimeClasspath() { fun testRuntimeClasspath() {
configureByFiles() configureByFiles()
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.config.SourceKotlinRootType
import org.jetbrains.kotlin.config.TestResourceKotlinRootType import org.jetbrains.kotlin.config.TestResourceKotlinRootType
import org.jetbrains.kotlin.config.TestSourceKotlinRootType import org.jetbrains.kotlin.config.TestSourceKotlinRootType
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.mppImportTestMinVersionForMaster
import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.platform.CommonPlatforms import org.jetbrains.kotlin.platform.CommonPlatforms
import org.jetbrains.kotlin.platform.js.JsPlatforms import org.jetbrains.kotlin.platform.js.JsPlatforms
@@ -45,7 +44,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.10+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.10+")
fun testProjectDependency() { fun testProjectDependency() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -226,7 +225,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testFileCollectionDependency() { fun testFileCollectionDependency() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -245,7 +244,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.30+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.30+")
fun testUnresolvedDependency() { fun testUnresolvedDependency() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -265,7 +264,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(gradleVersion = "5.0+", pluginVersion = "1.3.30+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(gradleVersion = "5.0+", pluginVersion = "1.3.30+")
fun testAndroidDependencyOnMPP() { fun testAndroidDependencyOnMPP() {
configureByFiles() configureByFiles()
createProjectSubFile( createProjectSubFile(
@@ -305,7 +304,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
libraryDependency("Gradle: org.hamcrest:hamcrest-core:1.3@jar", DependencyScope.TEST) libraryDependency("Gradle: org.hamcrest:hamcrest-core:1.3@jar", DependencyScope.TEST)
libraryDependency("Gradle: org.hamcrest:hamcrest-integration:1.3@jar", DependencyScope.TEST) libraryDependency("Gradle: org.hamcrest:hamcrest-integration:1.3@jar", DependencyScope.TEST)
libraryDependency("Gradle: org.hamcrest:hamcrest-library:1.3@jar", DependencyScope.TEST) libraryDependency("Gradle: org.hamcrest:hamcrest-library:1.3@jar", DependencyScope.TEST)
if (gradleKotlinPluginVersion != MINIMAL_SUPPORTED_VERSION) { if (gradleKotlinPluginVersion != RELEASED_A_YEAR_AGO_GRADLE_PLUGIN_VERSION) {
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-android-extensions-runtime:${gradleKotlinPluginVersion}@jar", DependencyScope.COMPILE) libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-android-extensions-runtime:${gradleKotlinPluginVersion}@jar", DependencyScope.COMPILE)
} }
libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}@jar", DependencyScope.COMPILE) libraryDependency("Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:${gradleKotlinPluginVersion}@jar", DependencyScope.COMPILE)
@@ -369,7 +368,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testTestTasks() { fun testTestTasks() {
val files = configureByFiles() val files = configureByFiles()
importProject(skipIndexing = true) importProject(skipIndexing = true)
@@ -412,7 +411,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.50+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.50+")
fun testImportTestsAndTargets() { fun testImportTestsAndTargets() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -440,7 +439,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
@Test @Test
@Ignore @Ignore
@PluginTargetVersions(gradleVersion = "5.0+", pluginVersion = "1.3.50+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(gradleVersion = "5.0+", pluginVersion = "1.3.50+")
fun testSingleAndroidTarget() { fun testSingleAndroidTarget() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -497,7 +496,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.10+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.10+")
fun testDependencyOnRoot() { fun testDependencyOnRoot() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -546,7 +545,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.10+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.10+")
fun testNestedDependencies() { fun testNestedDependencies() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -629,7 +628,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(gradleVersion = "5.0+", pluginVersion = "1.3.20+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(gradleVersion = "5.0+", pluginVersion = "1.3.20+")
fun testDetectAndroidSources() { fun testDetectAndroidSources() {
configureByFiles() configureByFiles()
createProjectSubFile( createProjectSubFile(
@@ -651,7 +650,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
* dependencies in multiplatform project included in composite build * dependencies in multiplatform project included in composite build
*/ */
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.20+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.20+")
fun testPlatformToCommonExpByInComposite() { fun testPlatformToCommonExpByInComposite() {
configureByFiles() configureByFiles()
importProject(true) importProject(true)
@@ -703,7 +702,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
* Test case for issue https://youtrack.jetbrains.com/issue/KT-29757 * Test case for issue https://youtrack.jetbrains.com/issue/KT-29757
*/ */
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.40+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.40+")
fun testJavaTransitiveOnMPP() { fun testJavaTransitiveOnMPP() {
configureByFiles() configureByFiles()
importProject(true) importProject(true)
@@ -769,7 +768,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
* Test case for issue https://youtrack.jetbrains.com/issue/KT-28822 * Test case for issue https://youtrack.jetbrains.com/issue/KT-28822
*/ */
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.41+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.41+")
fun testImportBeforeBuild() { fun testImportBeforeBuild() {
configureByFiles() configureByFiles()
importProject(true) importProject(true)
@@ -836,7 +835,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.20+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.20+")
fun testProductionOnTestFlag() { fun testProductionOnTestFlag() {
configureByFiles() configureByFiles()
importProject(true) importProject(true)
@@ -849,7 +848,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.30+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.30+")
fun testJvmWithJava() { fun testJvmWithJava() {
configureByFiles() configureByFiles()
importProject(true) importProject(true)
@@ -904,7 +903,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.30+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.30+")
fun testCommonTestTargetPlatform() { fun testCommonTestTargetPlatform() {
configureByFiles() configureByFiles()
importProject(true) importProject(true)
@@ -926,7 +925,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.60+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.60+")
fun testIgnoreIncompatibleNativeTestTasks() { fun testIgnoreIncompatibleNativeTestTasks() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -981,7 +980,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
@Test @Test
@PluginTargetVersions(pluginVersion = "1.3.30+", gradleVersionForLatestPlugin = mppImportTestMinVersionForMaster) @PluginTargetVersions(pluginVersion = "1.3.30+")
fun testMutableArtifactLists() { fun testMutableArtifactLists() {
configureByFiles() configureByFiles()
importProject(true) importProject(true)
@@ -8,14 +8,13 @@ package org.jetbrains.kotlin.gradle
import org.jetbrains.jps.model.java.JavaResourceRootType import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.jps.model.java.JavaSourceRootType import org.jetbrains.jps.model.java.JavaSourceRootType
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
import org.jetbrains.kotlin.idea.codeInsight.gradle.legacyMppImportTestMinVersionForMaster
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
class PackagePrefixImportingTest : MultiplePluginVersionGradleImportingTestCase() { class PackagePrefixImportingTest : MultiplePluginVersionGradleImportingTestCase() {
@Test @Test
@PluginTargetVersions(gradleVersionForLatestPlugin = legacyMppImportTestMinVersionForMaster) @PluginTargetVersions()
fun testPackagePrefixNonMPP() { fun testPackagePrefixNonMPP() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -13,14 +13,15 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager
import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions
import org.jetbrains.plugins.gradle.util.GradleConstants import org.jetbrains.plugins.gradle.util.GradleConstants
import org.junit.Ignore import org.junit.Ignore
import org.junit.Test import org.junit.Test
class GradleBuildFileHighlightingTest : GradleImportingTestCase() { class GradleBuildFileHighlightingTest : MultiplePluginVersionGradleImportingTestCase() {
@TargetVersions("4.8+") @PluginTargetVersions(gradleVersion = "4.8+")
@Test @Test
fun testKtsInJsProject() { fun testKtsInJsProject() {
val file = configureByFiles().buildGradleKtsFile() val file = configureByFiles().buildGradleKtsFile()
@@ -30,7 +31,7 @@ class GradleBuildFileHighlightingTest : GradleImportingTestCase() {
} }
@Ignore @Ignore
@TargetVersions("4.8+") @PluginTargetVersions(gradleVersion = "4.8+")
@Test @Test
fun testComplexBuildGradleKts() { fun testComplexBuildGradleKts() {
val file = configureByFiles().buildGradleKtsFile() val file = configureByFiles().buildGradleKtsFile()
@@ -12,11 +12,11 @@ import com.intellij.testFramework.runInEdtAndWait
import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.idea.configuration.KotlinWithGradleConfigurator import org.jetbrains.kotlin.idea.configuration.KotlinWithGradleConfigurator
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
class GradleConfiguratorPlatformSpecificTest : GradleImportingTestCase() { class GradleConfiguratorPlatformSpecificTest : MultiplePluginVersionGradleImportingTestCase() {
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportMultiplatform() { fun testEnableFeatureSupportMultiplatform() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -32,11 +32,11 @@ class GradleConfiguratorPlatformSpecificTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportMultiplatformWithXFlag() = testEnableFeatureSupportMultiplatform() fun testEnableFeatureSupportMultiplatformWithXFlag() = testEnableFeatureSupportMultiplatform()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportMultiplatform2() { fun testEnableFeatureSupportMultiplatform2() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -52,7 +52,7 @@ class GradleConfiguratorPlatformSpecificTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportMultiplatformToExistentArguments() { fun testEnableFeatureSupportMultiplatformToExistentArguments() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -68,7 +68,7 @@ class GradleConfiguratorPlatformSpecificTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportMultiplatformKts() { fun testEnableFeatureSupportMultiplatformKts() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -84,27 +84,27 @@ class GradleConfiguratorPlatformSpecificTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testAddLibraryMultiplatform() = doTestAddLibrary() fun testAddLibraryMultiplatform() = doTestAddLibrary()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testAddLibraryMultiplatformGSK() = doTestAddLibrary() fun testAddLibraryMultiplatformGSK() = doTestAddLibrary()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testAddLibraryMultiplatformGSK2() = doTestAddLibrary() fun testAddLibraryMultiplatformGSK2() = doTestAddLibrary()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testAddLibraryMultiplatformGSK3() = doTestAddLibrary() fun testAddLibraryMultiplatformGSK3() = doTestAddLibrary()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testAddLibraryMultiplatformGSK4() = doTestAddLibrary() fun testAddLibraryMultiplatformGSK4() = doTestAddLibrary()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testAddLibraryMultiplatformGSK5() = doTestAddLibrary() fun testAddLibraryMultiplatformGSK5() = doTestAddLibrary()
@@ -17,11 +17,11 @@ import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.test.testFramework.runWriteAction import org.jetbrains.kotlin.test.testFramework.runWriteAction
import org.jetbrains.plugins.gradle.execution.test.runner.GradleTestRunConfigurationProducer import org.jetbrains.plugins.gradle.execution.test.runner.GradleTestRunConfigurationProducer
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
class GradleConfiguratorTest : GradleImportingTestCase() { class GradleConfiguratorTest : MultiplePluginVersionGradleImportingTestCase() {
@Test @Test
fun testProjectWithModule() { fun testProjectWithModule() {
@@ -46,7 +46,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
""" """
<p>The compiler bundled to Kotlin plugin (1.0.0) is older than external compiler used for building modules:</p> <p>The compiler bundled to Kotlin plugin (1.0.0) is older than external compiler used for building modules:</p>
<ul> <ul>
<li>app (${LATEST_STABLE_GRADLE_PLUGIN_VERSION})</li> <li>app ($gradleKotlinPluginVersion)</li>
</ul> </ul>
<p>This may cause different set of errors and warnings reported in IDE.</p> <p>This may cause different set of errors and warnings reported in IDE.</p>
<p><a href="update">Update</a> <a href="ignore">Ignore</a></p> <p><a href="update">Update</a> <a href="ignore">Ignore</a></p>
@@ -120,7 +120,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJvmWithBuildGradle() { fun testConfigureJvmWithBuildGradle() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -137,7 +137,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJvmWithBuildGradleKts() { fun testConfigureJvmWithBuildGradleKts() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -154,7 +154,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJvmEAPWithBuildGradle() { fun testConfigureJvmEAPWithBuildGradle() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -171,7 +171,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJvmEAPWithBuildGradleKts() { fun testConfigureJvmEAPWithBuildGradleKts() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -188,7 +188,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJsWithBuildGradle() { fun testConfigureJsWithBuildGradle() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -205,7 +205,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJsWithBuildGradleKts() { fun testConfigureJsWithBuildGradleKts() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -222,7 +222,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJsEAPWithBuildGradle() { fun testConfigureJsEAPWithBuildGradle() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -239,7 +239,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.4+") @PluginTargetVersions(gradleVersion = "4.4+")
fun testConfigureJsEAPWithBuildGradleKts() { fun testConfigureJsEAPWithBuildGradleKts() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -330,6 +330,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testTestTasksAreImported() { fun testTestTasksAreImported() {
importProjectFromTestData() importProjectFromTestData()
@@ -338,6 +339,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testAddNonKotlinLibraryGSK() { fun testAddNonKotlinLibraryGSK() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -356,6 +358,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testAddTestLibraryGSK() { fun testAddTestLibraryGSK() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -381,6 +384,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testAddLibraryGSK() { fun testAddLibraryGSK() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -438,6 +442,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testChangeLanguageVersionGSK() { fun testChangeLanguageVersionGSK() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -483,7 +488,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testChangeFeatureSupportWithXFlag() = testChangeFeatureSupport() fun testChangeFeatureSupportWithXFlag() = testChangeFeatureSupport()
@@ -502,7 +507,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testDisableFeatureSupportWithXFlag() = testDisableFeatureSupport() fun testDisableFeatureSupportWithXFlag() = testDisableFeatureSupport()
@@ -521,7 +526,7 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
@JvmName("testEnableFeatureSupportWithXFlag") @JvmName("testEnableFeatureSupportWithXFlag")
fun testEnableFeatureSupportWithXFlag() = testEnableFeatureSupport() fun testEnableFeatureSupportWithXFlag() = testEnableFeatureSupport()
@@ -556,11 +561,12 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportToExistentArgumentsWithXFlag() = testEnableFeatureSupportToExistentArguments() fun testEnableFeatureSupportToExistentArgumentsWithXFlag() = testEnableFeatureSupportToExistentArguments()
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testChangeFeatureSupportGSK() { fun testChangeFeatureSupportGSK() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -575,11 +581,12 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testChangeFeatureSupportGSKWithXFlag() = testChangeFeatureSupportGSK() fun testChangeFeatureSupportGSKWithXFlag() = testChangeFeatureSupportGSK()
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testDisableFeatureSupportGSK() { fun testDisableFeatureSupportGSK() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -594,11 +601,13 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+")
@Test @Test
@PluginTargetVersions(gradleVersion = "4.7+")
fun testDisableFeatureSupportGSKWithXFlag() = testDisableFeatureSupportGSK() fun testDisableFeatureSupportGSKWithXFlag() = testDisableFeatureSupportGSK()
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testEnableFeatureSupportGSK() { fun testEnableFeatureSupportGSK() {
val files = importProjectFromTestData() val files = importProjectFromTestData()
@@ -613,15 +622,15 @@ class GradleConfiguratorTest : GradleImportingTestCase() {
} }
} }
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportGSKWithXFlag() = testEnableFeatureSupportGSK() fun testEnableFeatureSupportGSKWithXFlag() = testEnableFeatureSupportGSK()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportGSKWithNotInfixVersionCallAndXFlag() = testEnableFeatureSupportGSK() fun testEnableFeatureSupportGSKWithNotInfixVersionCallAndXFlag() = testEnableFeatureSupportGSK()
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+")
@Test @Test
fun testEnableFeatureSupportGSKWithSpecifyingPluginThroughIdAndXFlag() = testEnableFeatureSupportGSK() fun testEnableFeatureSupportGSKWithSpecifyingPluginThroughIdAndXFlag() = testEnableFeatureSupportGSK()
@@ -54,25 +54,25 @@ import org.jetbrains.kotlin.platform.js.JsPlatforms
import org.jetbrains.kotlin.platform.js.isJs import org.jetbrains.kotlin.platform.js.isJs
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.util.KtTestUtil import org.jetbrains.kotlin.test.util.KtTestUtil
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
internal fun GradleImportingTestCase.facetSettings(moduleName: String) = KotlinFacet.get(getModule(moduleName))!!.configuration.settings internal fun MultiplePluginVersionGradleImportingTestCase.facetSettings(moduleName: String) = KotlinFacet.get(getModule(moduleName))!!.configuration.settings
internal val GradleImportingTestCase.facetSettings: KotlinFacetSettings internal val MultiplePluginVersionGradleImportingTestCase.facetSettings: KotlinFacetSettings
get() = facetSettings("project_main") get() = facetSettings("project_main")
internal val GradleImportingTestCase.testFacetSettings: KotlinFacetSettings internal val MultiplePluginVersionGradleImportingTestCase.testFacetSettings: KotlinFacetSettings
get() = facetSettings("project_test") get() = facetSettings("project_test")
internal fun GradleImportingTestCase.getSourceRootInfos(moduleName: String): List<Pair<String, JpsModuleSourceRootType<*>>> { internal fun MultiplePluginVersionGradleImportingTestCase.getSourceRootInfos(moduleName: String): List<Pair<String, JpsModuleSourceRootType<*>>> {
return ModuleRootManager.getInstance(getModule(moduleName)).contentEntries.flatMap { return ModuleRootManager.getInstance(getModule(moduleName)).contentEntries.flatMap {
it.sourceFolders.map { it.url.replace(projectPath, "") to it.rootType } it.sourceFolders.map { it.url.replace(projectPath, "") to it.rootType }
} }
} }
class GradleFacetImportTest : GradleImportingTestCase() { class GradleFacetImportTest : MultiplePluginVersionGradleImportingTestCase() {
private fun assertSameKotlinSdks(vararg moduleNames: String) { private fun assertSameKotlinSdks(vararg moduleNames: String) {
val sdks = moduleNames.map { getModule(it).sdk!! } val sdks = moduleNames.map { getModule(it).sdk!! }
@@ -406,7 +406,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.9") @PluginTargetVersions(gradleVersion = "4.9")
fun testCommonImportByPlatformPlugin() { fun testCommonImportByPlatformPlugin() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -1,468 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.codeInsight.gradle
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.PathManager
import com.intellij.openapi.application.Result
import com.intellij.openapi.application.WriteAction
import com.intellij.openapi.externalSystem.importing.ImportSpec
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
import com.intellij.openapi.externalSystem.model.ProjectSystemId
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListenerAdapter
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.impl.LoadTextUtil
import com.intellij.openapi.fileTypes.FileTypeManager
import com.intellij.openapi.projectRoots.JavaSdk
import com.intellij.openapi.projectRoots.ProjectJdkTable
import com.intellij.openapi.projectRoots.Sdk
import com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.ui.TestDialog
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
import com.intellij.testFramework.IdeaTestUtil
import com.intellij.testFramework.RunAll
import com.intellij.testFramework.VfsTestUtil
import com.intellij.util.ArrayUtilRt
import com.intellij.util.PathUtil
import com.intellij.util.SmartList
import com.intellij.util.ThrowableRunnable
import com.intellij.util.containers.ContainerUtil
import junit.framework.TestCase
import org.gradle.StartParameter
import org.gradle.util.GradleVersion
import org.gradle.wrapper.GradleWrapperMain
import org.gradle.wrapper.PathAssembler
import org.intellij.lang.annotations.Language
import org.jetbrains.annotations.NonNls
import org.jetbrains.kotlin.idea.test.GradleProcessOutputInterceptor
import org.jetbrains.kotlin.idea.test.KotlinSdkCreationChecker
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.idea.util.getProjectJdkTableSafe
import org.jetbrains.kotlin.test.JUnitParameterizedWithIdeaConfigurationRunner
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.RunnerFactoryWithMuteInDatabase
import org.jetbrains.plugins.gradle.settings.DistributionType
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
import org.jetbrains.plugins.gradle.settings.GradleSettings
import org.jetbrains.plugins.gradle.settings.GradleSystemSettings
import org.jetbrains.plugins.gradle.util.GradleConstants
import org.jetbrains.plugins.gradle.util.GradleUtil
import org.jetbrains.plugins.groovy.GroovyFileType
import org.junit.AfterClass
import org.junit.Assume.assumeThat
import org.junit.Assume.assumeTrue
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.rules.TestName
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.io.File
import java.io.IOException
import java.io.StringWriter
import java.net.URISyntaxException
import java.util.*
import java.util.zip.ZipException
import java.util.zip.ZipFile
// part of org.jetbrains.plugins.gradle.importing.GradleImportingTestCase
@RunWith(value = JUnitParameterizedWithIdeaConfigurationRunner::class)
@Parameterized.UseParametersRunnerFactory(RunnerFactoryWithMuteInDatabase::class)
abstract class GradleImportingTestCase : ExternalSystemImportingTestCase() {
protected var sdkCreationChecker: KotlinSdkCreationChecker? = null
private val removedSdks: MutableList<Sdk> = SmartList()
@JvmField
@Rule
var name = TestName()
@JvmField
@Rule
var testWatcher = ImportingTestWatcher()
@JvmField
@Rule
var versionMatcherRule = VersionMatcherRule()
@JvmField
@Parameterized.Parameter
var gradleVersion: String = ""
private lateinit var myProjectSettings: GradleProjectSettings
private lateinit var myJdkHome: String
open fun isApplicableTest(): Boolean = true
open fun jvmHeapArgsByGradleVersion(version: String): String = when {
version.startsWith("4.") ->
// work-around due to memory leak in class loaders in gradle. The amount of used memory in the gradle daemon
// is drammatically increased on every reimport of project due to sequential compilation of build scripts.
// see more details in https://github.com/gradle/gradle/commit/b483d29f315758913791fe58d572fa6bafa0395c
"-Xmx256m -XX:MaxPermSize=64m"
else ->
// 128M should be enough for gradle 5.0+ (leak is fixed), and <4.0 (amount of tests is less)
"-Xms128M -Xmx256m -XX:MaxPermSize=64m"
}
override fun setUp() {
myJdkHome = IdeaTestUtil.requireRealJdkHome()
super.setUp()
assumeTrue(isApplicableTest())
assumeThat(gradleVersion, versionMatcherRule.matcher)
removedSdks.clear()
runWrite {
val jdkTable = getProjectJdkTableSafe()
jdkTable.findJdk(GRADLE_JDK_NAME)?.let {
jdkTable.removeJdk(it)
}
val jdkHomeDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(File(myJdkHome))!!
val jdk = SdkConfigurationUtil.setupSdk(arrayOfNulls(0), jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME)
TestCase.assertNotNull("Cannot create JDK for $myJdkHome", jdk)
if (!jdkTable.allJdks.contains(jdk)) {
(jdkTable as ProjectJdkTableImpl).addTestJdk(jdk!!, testRootDisposable)
ProjectRootManager.getInstance(myProject).projectSdk = jdk
}
FileTypeManager.getInstance().associateExtension(GroovyFileType.GROOVY_FILE_TYPE, "gradle")
}
myProjectSettings = GradleProjectSettings().apply {
this.isUseQualifiedModuleNames = false
}
System.setProperty(ExternalSystemExecutionSettings.REMOTE_PROCESS_IDLE_TTL_IN_MS_KEY, GRADLE_DAEMON_TTL_MS.toString())
val distribution = WriteAction.computeAndWait<PathAssembler.LocalDistribution, Throwable> { configureWrapper() }
val allowedRoots = ArrayList<String>()
collectAllowedRoots(allowedRoots, distribution)
if (!allowedRoots.isEmpty()) {
VfsRootAccess.allowRootAccess(myTestFixture.testRootDisposable, *ArrayUtilRt.toStringArray(allowedRoots))
}
GradleSettings.getInstance(myProject).gradleVmOptions =
"${jvmHeapArgsByGradleVersion(gradleVersion)} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${System.getProperty("user.dir")}"
sdkCreationChecker = KotlinSdkCreationChecker()
GradleProcessOutputInterceptor.install(testRootDisposable)
}
override fun tearDown() {
if (myJdkHome == null) {
//super.setUp() wasn't called
return
}
RunAll(
ThrowableRunnable {
runWrite {
Arrays.stream(ProjectJdkTable.getInstance().allJdks).forEach { jdk: Sdk ->
(ProjectJdkTable.getInstance() as ProjectJdkTableImpl).removeTestJdk(jdk)
if (jdk is Disposable) {
Disposer.dispose((jdk as Disposable))
}
}
for (sdk in removedSdks) {
SdkConfigurationUtil.addSdk(sdk)
}
removedSdks.clear()
}
},
ThrowableRunnable {
Messages.setTestDialog(TestDialog.DEFAULT)
deleteBuildSystemDirectory()
// was FileUtil.delete(BuildManager.getInstance().buildSystemDirectory.toFile())
sdkCreationChecker?.removeNewKotlinSdk()
},
ThrowableRunnable {
super.tearDown()
}
).run()
}
override fun collectAllowedRoots(roots: MutableList<String>) {
super.collectAllowedRoots(roots)
roots.add(myJdkHome)
roots.addAll(ExternalSystemTestCase.collectRootsInside(myJdkHome))
roots.add(PathManager.getConfigPath())
}
protected open fun collectAllowedRoots(
roots: MutableList<String>,
distribution: PathAssembler.LocalDistribution?
) {
//Note: could be required to use:
//Environment.getEnvVariable("JAVA_HOME")
roots.add(myJdkHome)
}
override fun getName(): String {
return if (name.methodName == null) super.getName() else FileUtil.sanitizeFileName(name.methodName)
}
override fun getExternalSystemConfigFileName(): String = "build.gradle"
@Throws(IOException::class)
protected open fun importProjectUsingSingeModulePerGradleProject(config: String? = null, skipIndexing: Boolean? = null) {
currentExternalProjectSettings.isResolveModulePerSourceSet = false
importProject(config, skipIndexing)
}
open fun importProject() {
importProject(skipIndexing = null)
}
override fun importProject(skipIndexing: Boolean?) {
ExternalSystemApiUtil.subscribe(
myProject,
GradleConstants.SYSTEM_ID,
object : ExternalSystemSettingsListenerAdapter<ExternalProjectSettings>() {
override fun onProjectsLinked(settings: Collection<ExternalProjectSettings>) {
val item = ContainerUtil.getFirstItem<Any>(settings)
if (item is GradleProjectSettings) {
item.gradleJvm = GRADLE_JDK_NAME
}
}
})
super.importProject(skipIndexing)
}
@Throws(IOException::class)
override fun importProject(@NonNls @Language("Groovy") config: String?, skipIndexing: Boolean?) {
var config = config
config = injectRepo(config)
super.importProject(config, skipIndexing)
}
override fun handleImportFailure(errorMessage: String, errorDetails: String?) {
val gradleOutput = GradleProcessOutputInterceptor.getInstance()?.getOutput().orEmpty()
// Typically Gradle error message consists of a line with the description of the error followed by
// a multi-line stacktrace. The idea is to cut off the stacktrace if it is already contained in
// the intercepted Gradle process output to avoid unnecessary verbosity.
val compactErrorMessage = when (val indexOfNewLine = errorMessage.indexOf('\n')) {
-1 -> errorMessage
else -> {
val compactErrorMessage = errorMessage.substring(0, indexOfNewLine)
val theRest = errorMessage.substring(indexOfNewLine + 1)
if (theRest in gradleOutput) compactErrorMessage else errorMessage
}
}
val failureMessage = buildString {
append("Gradle import failed: ").append(compactErrorMessage).append('\n')
if (!errorDetails.isNullOrBlank()) append("Error details: ").append(errorDetails).append('\n')
append("Gradle process output (BEGIN):\n")
append(gradleOutput)
if (!gradleOutput.endsWith('\n')) append('\n')
append("Gradle process output (END)")
}
fail(failureMessage)
}
protected open fun injectRepo(@NonNls @Language("Groovy") config: String?): String {
var config = config ?: ""
config = """allprojects {
repositories {
maven {
url 'https://repo.labs.intellij.net/repo1'
}
}}
$config"""
return config
}
override fun createImportSpec(): ImportSpec? {
val importSpecBuilder = ImportSpecBuilder(super.createImportSpec())
importSpecBuilder.withArguments("--stacktrace")
return importSpecBuilder.build()
}
override fun getCurrentExternalProjectSettings(): GradleProjectSettings = myProjectSettings
override fun getExternalSystemId(): ProjectSystemId = GradleConstants.SYSTEM_ID
@Throws(IOException::class)
protected open fun createSettingsFile(@NonNls @Language("Groovy") content: String?): VirtualFile? {
return createProjectSubFile("settings.gradle", content)
}
@Throws(IOException::class, URISyntaxException::class)
private fun configureWrapper(): PathAssembler.LocalDistribution {
val distributionUri = AbstractModelBuilderTest.DistributionLocator().getDistributionFor(GradleVersion.version(gradleVersion))
myProjectSettings.distributionType = DistributionType.DEFAULT_WRAPPED
val wrapperJarFrom = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(wrapperJar())!!
val wrapperJarFromTo = createProjectSubFile("gradle/wrapper/gradle-wrapper.jar")
runWrite {
wrapperJarFromTo.setBinaryContent(wrapperJarFrom.contentsToByteArray())
}
val properties = Properties()
properties.setProperty("distributionBase", "GRADLE_USER_HOME")
properties.setProperty("distributionPath", "wrapper/dists")
properties.setProperty("zipStoreBase", "GRADLE_USER_HOME")
properties.setProperty("zipStorePath", "wrapper/dists")
properties.setProperty("distributionUrl", distributionUri.toString())
val writer = StringWriter()
properties.store(writer, null)
createProjectSubFile("gradle/wrapper/gradle-wrapper.properties", writer.toString())
val wrapperConfiguration =
GradleUtil.getWrapperConfiguration(projectPath)
val localDistribution = PathAssembler(
StartParameter.DEFAULT_GRADLE_USER_HOME
).getDistribution(wrapperConfiguration)
val zip = localDistribution.zipFile
try {
if (zip.exists()) {
val zipFile = ZipFile(zip)
zipFile.close()
}
} catch (e: ZipException) {
e.printStackTrace()
println("Corrupted file will be removed: " + zip.path)
FileUtil.delete(zip)
} catch (e: IOException) {
e.printStackTrace()
}
return localDistribution
}
protected open fun testDataDirName(): String = ""
protected open fun testDataDirectory(): File {
val baseDir = "${PluginTestCaseBase.getTestDataPathBase()}/gradle/${testDataDirName()}/"
return File(baseDir, getTestName(true).substringBefore("_"))
}
protected fun configureKotlinVersionAndProperties(text: String, properties: Map<String, String>? = null): String {
var result = text
(properties ?: mapOf("kotlin_plugin_version" to LATEST_STABLE_GRADLE_PLUGIN_VERSION)).forEach { (key, value) ->
result = result.replace("{{${key}}}", value)
}
return result
}
protected open fun configureByFiles(properties: Map<String, String>? = null): List<VirtualFile> {
val rootDir = testDataDirectory()
assert(rootDir.exists()) { "Directory ${rootDir.path} doesn't exist" }
return rootDir.walk().mapNotNull {
when {
it.isDirectory -> null
!it.name.endsWith(SUFFIX) -> {
val text = configureKotlinVersionAndProperties(FileUtil.loadFile(it, /* convertLineSeparators = */ true), properties)
val virtualFile = createProjectSubFile(it.path.substringAfter(rootDir.path + File.separator), text)
// Real file with expected testdata allows to throw nicer exceptions in
// case of mismatch, as well as open interactive diff window in IDEA
virtualFile.putUserData(VfsTestUtil.TEST_DATA_FILE_PATH, it.absolutePath)
virtualFile
}
else -> null
}
}.toList()
}
protected fun importProjectFromTestData(skipIndexing: Boolean? = null): List<VirtualFile> {
val files = configureByFiles()
importProject(skipIndexing)
return files
}
protected fun checkFiles(files: List<VirtualFile>) {
FileDocumentManager.getInstance().saveAllDocuments()
files.filter {
it.name == GradleConstants.DEFAULT_SCRIPT_NAME
|| it.name == GradleConstants.KOTLIN_DSL_SCRIPT_NAME
|| it.name == GradleConstants.SETTINGS_FILE_NAME
}
.forEach {
if (it.name == GradleConstants.SETTINGS_FILE_NAME && !File(testDataDirectory(), it.name + SUFFIX).exists()) return@forEach
val actualText = configureKotlinVersionAndProperties(LoadTextUtil.loadText(it).toString())
val expectedFileName = if (File(testDataDirectory(), it.name + ".$gradleVersion" + SUFFIX).exists()) {
it.name + ".$gradleVersion" + SUFFIX
} else {
it.name + SUFFIX
}
KotlinTestUtils.assertEqualsToFile(File(testDataDirectory(), expectedFileName), actualText)
{ s -> configureKotlinVersionAndProperties(s) }
}
}
private fun runWrite(f: () -> Unit) {
object : WriteAction<Any>() {
override fun run(result: Result<Any>) {
f()
}
}.execute()
}
protected open fun enableGradleDebugWithSuspend() {
GradleSystemSettings.getInstance().gradleVmOptions = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
}
companion object {
const val GRADLE_JDK_NAME = "Gradle JDK"
private const val GRADLE_DAEMON_TTL_MS = 10000
@JvmStatic
protected val SUFFIX = ".after"
@JvmStatic
@Parameterized.Parameters(name = "{index}: with Gradle-{0}")
fun data(): Collection<Array<Any>> {
return listOf(*AbstractModelBuilderTest.SUPPORTED_GRADLE_VERSIONS)
}
fun wrapperJar(): File {
return File(PathUtil.getJarPathForClass(GradleWrapperMain::class.java))
}
private var logSaver: GradleImportingTestLogSaver? = null
@JvmStatic
@BeforeClass
fun setLoggerFactory() {
logSaver = GradleImportingTestLogSaver()
}
@JvmStatic
@AfterClass
fun restoreLoggerFactory() {
logSaver?.restore()
}
}
}
@@ -23,15 +23,16 @@ import com.intellij.openapi.vfs.VirtualFile
import com.intellij.testFramework.runInEdtAndWait import com.intellij.testFramework.runInEdtAndWait
import org.jetbrains.kotlin.idea.inspections.gradle.DifferentKotlinGradleVersionInspection import org.jetbrains.kotlin.idea.inspections.gradle.DifferentKotlinGradleVersionInspection
import org.jetbrains.kotlin.idea.inspections.runInspection import org.jetbrains.kotlin.idea.inspections.runInspection
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import java.io.File import java.io.File
class GradleInspectionTest : GradleImportingTestCase() { class GradleInspectionTest : MultiplePluginVersionGradleImportingTestCase() {
// Disable gradle inspection tests in AndroidStudio as they are disabled in distribution // Disable gradle inspection tests in AndroidStudio as they are disabled in distribution
override fun isApplicableTest(): Boolean = isGradleInspectionTestApplicable() override fun isApplicableTest(): Boolean = isGradleInspectionTestApplicable() && super.isApplicableTest()
@Test @Test
@@ -71,10 +72,14 @@ class GradleInspectionTest : GradleImportingTestCase() {
val problems = getInspectionResultFromTestDataProject() val problems = getInspectionResultFromTestDataProject()
Assert.assertEquals(1, problems.size) Assert.assertEquals(1, problems.size)
Assert.assertEquals("Plugin version ($LATEST_STABLE_GRADLE_PLUGIN_VERSION) is not the same as library version (1.3.30)", problems.single()) Assert.assertEquals(
"Plugin version ($gradleKotlinPluginVersion) is not the same as library version (1.3.30)",
problems.single()
)
} }
@Test @Test
@PluginTargetVersions(pluginVersion = "<1.5.20")
fun testDifferentKotlinGradleVersion() { fun testDifferentKotlinGradleVersion() {
val tool = DifferentKotlinGradleVersionInspection() val tool = DifferentKotlinGradleVersionInspection()
tool.testVersionMessage = "\$PLUGIN_VERSION" tool.testVersionMessage = "\$PLUGIN_VERSION"
@@ -82,20 +87,20 @@ class GradleInspectionTest : GradleImportingTestCase() {
Assert.assertEquals(1, problems.size) Assert.assertEquals(1, problems.size)
Assert.assertEquals( Assert.assertEquals(
"Kotlin version that is used for building with Gradle ($LATEST_STABLE_GRADLE_PLUGIN_VERSION) differs from the one bundled into the IDE plugin (\$PLUGIN_VERSION)", "Kotlin version that is used for building with Gradle ($gradleKotlinPluginVersion) differs from the one bundled into the IDE plugin (\$PLUGIN_VERSION)",
problems.single() problems.single()
) )
} }
@Test @Test
@TargetVersions("4.9") @PluginTargetVersions(gradleVersion = "4.9")
fun testJreInOldVersion() { fun testJreInOldVersion() {
val problems = getInspectionResultFromTestDataProject() val problems = getInspectionResultFromTestDataProject()
Assert.assertTrue("The inspection result should be empty but contains the following elements: [$problems].", problems.isEmpty()) Assert.assertTrue("The inspection result should be empty but contains the following elements: [$problems].", problems.isEmpty())
} }
@Test @Test
@TargetVersions("4.9") @PluginTargetVersions(gradleVersion = "4.9")
fun testJreIsDeprecated() { fun testJreIsDeprecated() {
val problems = getInspectionResultFromTestDataProject() val problems = getInspectionResultFromTestDataProject()
@@ -107,7 +112,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.9") @PluginTargetVersions(gradleVersion = "4.9")
fun testJreIsDeprecatedWithImplementation() { fun testJreIsDeprecatedWithImplementation() {
val problems = getInspectionResultFromTestDataProject() val problems = getInspectionResultFromTestDataProject()
@@ -118,7 +123,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
) )
} }
@TargetVersions("4.9") @PluginTargetVersions(gradleVersion = "4.9")
@Test @Test
fun testJreIsDeprecatedWithoutImplicitVersion() { fun testJreIsDeprecatedWithoutImplicitVersion() {
val problems = getInspectionResultFromTestDataProject() val problems = getInspectionResultFromTestDataProject()
@@ -145,7 +150,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.9") @PluginTargetVersions(gradleVersion = "4.9")
fun testObsoleteCoroutinesUsage() { fun testObsoleteCoroutinesUsage() {
val problems = getInspectionResultFromTestDataProject() val problems = getInspectionResultFromTestDataProject()
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.idea.codeInsight.gradle package org.jetbrains.kotlin.idea.codeInsight.gradle
import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.testFramework.Parameterized
import junit.framework.AssertionFailedError import junit.framework.AssertionFailedError
import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle
import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager
@@ -21,19 +22,13 @@ import org.jetbrains.kotlin.scripting.definitions.ScriptDefinition
import org.jetbrains.kotlin.scripting.resolve.ScriptCompilationConfigurationWrapper import org.jetbrains.kotlin.scripting.resolve.ScriptCompilationConfigurationWrapper
import org.jetbrains.kotlin.test.JUnitParameterizedWithIdeaConfigurationRunner import org.jetbrains.kotlin.test.JUnitParameterizedWithIdeaConfigurationRunner
import org.jetbrains.plugins.gradle.settings.GradleSettings import org.jetbrains.plugins.gradle.settings.GradleSettings
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.junit.runners.Parameterized.Parameters
import java.io.File import java.io.File
@RunWith(value = JUnitParameterizedWithIdeaConfigurationRunner::class) @RunWith(value = JUnitParameterizedWithIdeaConfigurationRunner::class)
class GradleKtsImportTest : GradleImportingTestCase() { class GradleKtsImportTest : MultiplePluginVersionGradleImportingTestCase() {
companion object {
@JvmStatic
@Parameters(name = "{index}: with Gradle-{0}")
fun data(): Collection<Array<Any?>> = listOf(arrayOf<Any?>("6.0.1"))
}
val scriptConfigurationManager get() = ScriptConfigurationManager.getInstance(myProject) as CompositeScriptConfigurationManager val scriptConfigurationManager get() = ScriptConfigurationManager.getInstance(myProject) as CompositeScriptConfigurationManager
val projectDir get() = File(GradleSettings.getInstance(myProject).linkedProjectsSettings.first().externalProjectPath) val projectDir get() = File(GradleSettings.getInstance(myProject).linkedProjectsSettings.first().externalProjectPath)
@@ -47,7 +42,7 @@ class GradleKtsImportTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("6.0.1+") @PluginTargetVersions(gradleVersion = "6.0.1+")
fun testEmpty() { fun testEmpty() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -56,7 +51,7 @@ class GradleKtsImportTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("6.0.1+") @PluginTargetVersions(gradleVersion = "6.0.1+")
fun testError() { fun testError() {
configureByFiles() configureByFiles()
@@ -72,7 +67,7 @@ class GradleKtsImportTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("6.0.1+") @PluginTargetVersions(gradleVersion = "6.0.1+")
fun testCompositeBuild() { fun testCompositeBuild() {
configureByFiles() configureByFiles()
importProject() importProject()
@@ -16,15 +16,15 @@ import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectService import org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectService
import org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectService.MigrationTestState import org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectService.MigrationTestState
import org.jetbrains.kotlin.idea.configuration.MigrationInfo import org.jetbrains.kotlin.idea.configuration.MigrationInfo
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException import java.util.concurrent.TimeoutException
class GradleMigrateTest : GradleImportingTestCase() { class GradleMigrateTest : MultiplePluginVersionGradleImportingTestCase() {
@Test @Test
@TargetVersions("5.3+") @PluginTargetVersions(gradleVersion = "5.3+", pluginVersion = "1.4.0+")
fun testMigrateStdlib() { fun testMigrateStdlib() {
val migrateComponentState = doMigrationTest( val migrateComponentState = doMigrationTest(
beforeText = """ beforeText = """
@@ -44,37 +44,37 @@ class GradleMigrateTest : GradleImportingTestCase() {
compile "org.jetbrains.kotlin:kotlin-stdlib:1.3.40" compile "org.jetbrains.kotlin:kotlin-stdlib:1.3.40"
} }
""", """,
//ToDo: Change 1.4-M3 to 1.4.0 version after release
afterText = afterText =
""" """
buildscript { buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0-rc" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$gradleKotlinPluginVersion"
} }
} }
apply plugin: 'kotlin' apply plugin: 'kotlin'
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:1.4.0-rc" compile "org.jetbrains.kotlin:kotlin-stdlib:$gradleKotlinPluginVersion"
} }
""" """
) )
Assert.assertEquals(false, migrateComponentState?.hasApplicableTools) Assert.assertEquals(false, migrateComponentState?.hasApplicableTools)
val newLanguageVersion = LanguageVersion.fromFullVersionString(gradleKotlinPluginVersion)!!
Assert.assertEquals( Assert.assertEquals(
MigrationInfo.create( MigrationInfo.create(
oldStdlibVersion = "1.3.40", oldStdlibVersion = "1.3.40",
oldApiVersion = ApiVersion.KOTLIN_1_3, oldApiVersion = ApiVersion.KOTLIN_1_3,
oldLanguageVersion = LanguageVersion.KOTLIN_1_3, oldLanguageVersion = LanguageVersion.KOTLIN_1_3,
newStdlibVersion = "1.4.0-rc", newStdlibVersion = gradleKotlinPluginVersion,
newApiVersion = ApiVersion.KOTLIN_1_4, newApiVersion = ApiVersion.createByLanguageVersion(newLanguageVersion),
newLanguageVersion = LanguageVersion.KOTLIN_1_4 newLanguageVersion = newLanguageVersion
), ),
migrateComponentState?.migrationInfo migrateComponentState?.migrationInfo
) )
@@ -22,7 +22,7 @@ import org.junit.Test
import java.io.File import java.io.File
import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KMutableProperty0
class GradleQuickFixTest : GradleImportingTestCase() { class GradleQuickFixTest : MultiplePluginVersionGradleImportingTestCase() {
private lateinit var codeInsightTestFixture: CodeInsightTestFixture private lateinit var codeInsightTestFixture: CodeInsightTestFixture
override fun testDataDirName() = "fixes" override fun testDataDirName() = "fixes"
@@ -18,26 +18,31 @@ import org.jetbrains.kotlin.gradle.GradleDaemonAnalyzerTestCase
import org.jetbrains.kotlin.gradle.checkFiles import org.jetbrains.kotlin.gradle.checkFiles
import org.jetbrains.kotlin.test.TagsTestDataUtil import org.jetbrains.kotlin.test.TagsTestDataUtil
import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
import java.io.File import java.io.File
class GradleTestRunConfigurationAndHighlightingTest : GradleImportingTestCase() { class GradleTestRunConfigurationAndHighlightingTest : MultiplePluginVersionGradleImportingTestCase() {
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testExpectClassWithTests() { fun testExpectClassWithTests() {
doTest() doTest()
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun preferredConfigurations() { fun preferredConfigurations() {
doTest() doTest()
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun multiplatformTestsInObject() { fun multiplatformTestsInObject() {
doTest() doTest()
} }
@Test @Test
@PluginTargetVersions(skipForMaster = true)
fun testMultiprojectBuild() { fun testMultiprojectBuild() {
doTest() doTest()
} }
@@ -15,12 +15,12 @@ import org.jetbrains.kotlin.idea.run.getConfiguration
import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer import org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer
import org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer import org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
class GradleTestRunConfigurationCustomTest : GradleImportingTestCase() { class GradleTestRunConfigurationCustomTest : MultiplePluginVersionGradleImportingTestCase() {
@Test @Test
@TargetVersions("4.7+") @PluginTargetVersions(gradleVersion = "4.7+", skipForMaster = true)
fun testPreferredConfigurations() { fun testPreferredConfigurations() {
if (!PlatformUtils.isIntelliJ()) { if (!PlatformUtils.isIntelliJ()) {
return return
@@ -25,12 +25,12 @@ import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
import com.intellij.testFramework.runInEdtAndWait import com.intellij.testFramework.runInEdtAndWait
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
import java.io.File import java.io.File
import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KMutableProperty0
class GradleUpdateConfigurationQuickFixTest : GradleImportingTestCase() { class GradleUpdateConfigurationQuickFixTest : MultiplePluginVersionGradleImportingTestCase() {
private lateinit var codeInsightTestFixture: CodeInsightTestFixture private lateinit var codeInsightTestFixture: CodeInsightTestFixture
fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/gradle/languageFeature/" + getTestName(true).substringBefore('_') fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/gradle/languageFeature/" + getTestName(true).substringBefore('_')
@@ -49,25 +49,25 @@ class GradleUpdateConfigurationQuickFixTest : GradleImportingTestCase() {
} }
@Test @Test
@TargetVersions("4.7 <=> 6.0") @PluginTargetVersions(gradleVersion = "4.7 <=> 6.0")
fun testUpdateLanguageVersion() { fun testUpdateLanguageVersion() {
doTest("Set module language version to 1.1") doTest("Set module language version to 1.1")
} }
@Test @Test
@TargetVersions("4.7 <=> 6.0") @PluginTargetVersions(gradleVersion = "4.7 <=> 6.0")
fun testUpdateApiVersion() { fun testUpdateApiVersion() {
doTest("Set module API version to 1.1") doTest("Set module API version to 1.1")
} }
@Test @Test
@TargetVersions("4.7 <=> 6.0") @PluginTargetVersions(gradleVersion = "4.7 <=> 6.0")
fun testUpdateLanguageAndApiVersion() { fun testUpdateLanguageAndApiVersion() {
doTest("Set module language version to 1.1") doTest("Set module language version to 1.1")
} }
@Test @Test
@TargetVersions("4.7 <=> 6.0") @PluginTargetVersions(gradleVersion = "4.7 <=> 6.0")
fun testAddKotlinReflect() { fun testAddKotlinReflect() {
doTest("Add 'kotlin-reflect.jar' to the classpath") doTest("Add 'kotlin-reflect.jar' to the classpath")
} }
@@ -75,7 +75,7 @@ class GradleUpdateConfigurationQuickFixTest : GradleImportingTestCase() {
private fun doTest(intentionName: String) { private fun doTest(intentionName: String) {
val buildGradleVFile = createProjectSubFile("build.gradle", File(getTestDataPath(), "build.gradle").readText()) val buildGradleVFile = createProjectSubFile("build.gradle", File(getTestDataPath(), "build.gradle").readText())
val sourceVFile = createProjectSubFile("src/main/kotlin/src.kt", File(getTestDataPath(), "src.kt").readText()) val sourceVFile = createProjectSubFile("src/main/kotlin/src.kt", File(getTestDataPath(), "src.kt").readText())
importProject() importProject(false)
runInEdtAndWait { runInEdtAndWait {
codeInsightTestFixture.configureFromExistingVirtualFile(sourceVFile) codeInsightTestFixture.configureFromExistingVirtualFile(sourceVFile)
codeInsightTestFixture.launchAction(codeInsightTestFixture.findSingleIntention(intentionName)) codeInsightTestFixture.launchAction(codeInsightTestFixture.findSingleIntention(intentionName))
@@ -102,7 +102,9 @@ abstract class MultiplePluginVersionGradleImportingTestCase : ExternalSystemImpo
@JvmField @JvmField
@Parameterized.Parameter(1) @Parameterized.Parameter(1)
var gradleKotlinPluginVersion: String = "" var gradleKotlinPluginParameter: String = ""
open val gradleKotlinPluginVersion: String get() = if (gradleKotlinPluginParameter == "master") MASTER_VERSION_OF_PLUGIN else gradleKotlinPluginParameter
@Rule @Rule
@JvmField @JvmField
@@ -133,7 +135,7 @@ abstract class MultiplePluginVersionGradleImportingTestCase : ExternalSystemImpo
"-Xmx256m -XX:MaxPermSize=64m" "-Xmx256m -XX:MaxPermSize=64m"
else -> else ->
// 128M should be enough for gradle 5.0+ (leak is fixed), and <4.0 (amount of tests is less) // 128M should be enough for gradle 5.0+ (leak is fixed), and <4.0 (amount of tests is less)
"-Xms128M -Xmx192m -XX:MaxPermSize=64m" "-Xms128M -Xmx256m -XX:MaxPermSize=64m"
} }
override fun setUp() { override fun setUp() {
@@ -443,23 +445,19 @@ abstract class MultiplePluginVersionGradleImportingTestCase : ExternalSystemImpo
private fun getDefaultPropertiesMap(): Map<String, String> { private fun getDefaultPropertiesMap(): Map<String, String> {
val defaultProperties = HashMap<String, String>() val defaultProperties = HashMap<String, String>()
defaultProperties["kotlin_plugin_version"] = gradleKotlinPluginVersion defaultProperties["kotlin_plugin_version"] = gradleKotlinPluginVersion
defaultProperties["kotlin_plugin_repositories"] = repositories(false) defaultProperties["kotlin_plugin_repositories"] = repositories()
defaultProperties["kts_kotlin_plugin_repositories"] = repositories(true) defaultProperties["kts_kotlin_plugin_repositories"] = repositories()
return defaultProperties return defaultProperties
} }
private fun repositories(useKts: Boolean): String { private fun repositories(): String {
val customRepositories = arrayOf(
"https://dl.bintray.com/kotlin/kotlin-dev",
)
val customMavenRepositories = customRepositories.joinToString("\n") { if (useKts) "maven(\"$it\")" else "maven { url '$it' } " }
return """ return """
mavenCentral()
mavenLocal() mavenLocal()
mavenCentral()
gradlePluginPortal()
google() google()
jcenter() jcenter()
$customMavenRepositories
""".trimIndent() """.trimIndent()
} }
@@ -476,6 +474,7 @@ abstract class MultiplePluginVersionGradleImportingTestCase : ExternalSystemImpo
const val RELEASED_A_YEAR_AGO_GRADLE_PLUGIN_VERSION = "1.3.72" const val RELEASED_A_YEAR_AGO_GRADLE_PLUGIN_VERSION = "1.3.72"
const val LATEST_STABLE_RELEASE_GRADLE_PLUGIN_VERSION = "1.4.30" const val LATEST_STABLE_RELEASE_GRADLE_PLUGIN_VERSION = "1.4.30"
val MASTER_VERSION_OF_PLUGIN val MASTER_VERSION_OF_PLUGIN
get() = File("libraries/tools/kotlin-gradle-plugin/build/libs").listFiles()?.map { it.name } get() = File("libraries/tools/kotlin-gradle-plugin/build/libs").listFiles()?.map { it.name }
?.firstOrNull { it.contains("-original.jar") }?.replace( ?.firstOrNull { it.contains("-original.jar") }?.replace(
@@ -485,13 +484,13 @@ abstract class MultiplePluginVersionGradleImportingTestCase : ExternalSystemImpo
const val LATEST_SUPPORTED_GRADLE_VERSION = "6.5.1" const val LATEST_SUPPORTED_GRADLE_VERSION = "6.5.1"
val SUPPORTED_GRADLE_VERSIONS = arrayOf("4.9", "5.6.4", LATEST_SUPPORTED_GRADLE_VERSION) val SUPPORTED_GRADLE_VERSIONS = arrayOf("4.9", "6.1.1", LATEST_SUPPORTED_GRADLE_VERSION)
private val LOCAL_RUN_PARAMS: Array<Any> = private val LOCAL_RUN_PARAMS: Array<Any> =
System.getenv("IMPORTING_TESTS_LOCAL_RUN_PARAMS") // You can specify versions for local run. For example: "6.7.1:1.4.30" System.getenv("IMPORTING_TESTS_LOCAL_RUN_PARAMS") // You can specify versions for local run. For example: "6.7.1:1.4.30"
?.replace(" ", "") ?.replace(" ", "")
?.split(":")?.toTypedArray() ?.split(":")?.toTypedArray()
?: arrayOf(LATEST_SUPPORTED_GRADLE_VERSION, MASTER_VERSION_OF_PLUGIN) ?: arrayOf(LATEST_SUPPORTED_GRADLE_VERSION, "master")
private val isTeamcityBuild = UsefulTestCase.IS_UNDER_TEAMCITY private val isTeamcityBuild = UsefulTestCase.IS_UNDER_TEAMCITY
@@ -499,17 +498,16 @@ abstract class MultiplePluginVersionGradleImportingTestCase : ExternalSystemImpo
@Parameterized.Parameters(name = "{index}: Gradle-{0}, KotlinGradlePlugin-{1}") @Parameterized.Parameters(name = "{index}: Gradle-{0}, KotlinGradlePlugin-{1}")
fun data(): Collection<Array<Any>> { fun data(): Collection<Array<Any>> {
if (isTeamcityBuild) if (isTeamcityBuild)
return listOf(LOCAL_RUN_PARAMS) return (SUPPORTED_GRADLE_VERSIONS).flatMap { gradleVersion ->
arrayOf(
return (SUPPORTED_GRADLE_VERSIONS).flatMap { gradleVersion -> RELEASED_A_YEAR_AGO_GRADLE_PLUGIN_VERSION,
arrayOf( LATEST_STABLE_RELEASE_GRADLE_PLUGIN_VERSION,
RELEASED_A_YEAR_AGO_GRADLE_PLUGIN_VERSION, "master"
LATEST_STABLE_RELEASE_GRADLE_PLUGIN_VERSION, ).map { pluginVersion ->
MASTER_VERSION_OF_PLUGIN arrayOf(gradleVersion, pluginVersion)
).map { pluginVersion -> }
arrayOf(gradleVersion, pluginVersion)
} }
} return listOf(LOCAL_RUN_PARAMS)
} }
} }
} }
@@ -12,7 +12,7 @@ import com.intellij.execution.actions.ConfigurationFromContext
import org.jetbrains.kotlin.gradle.GradleDaemonAnalyzerTestCase import org.jetbrains.kotlin.gradle.GradleDaemonAnalyzerTestCase
import org.jetbrains.kotlin.test.TagsTestDataUtil import org.jetbrains.kotlin.test.TagsTestDataUtil
import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.jetbrains.plugins.gradle.tooling.annotation.PluginTargetVersions
import org.junit.Test import org.junit.Test
class NativeRunConfigurationTest : MasterPluginVersionGradleImportingTestCase() { class NativeRunConfigurationTest : MasterPluginVersionGradleImportingTestCase() {
@@ -20,13 +20,13 @@ class NativeRunConfigurationTest : MasterPluginVersionGradleImportingTestCase()
override fun testDataDirName(): String = "nativeRunConfiguration" override fun testDataDirName(): String = "nativeRunConfiguration"
@Test @Test
@TargetVersions("6.0+") @PluginTargetVersions(gradleVersion = "6.0+")
fun multiplatformNativeRunGutter() { fun multiplatformNativeRunGutter() {
doTest() doTest()
} }
@Test @Test
@TargetVersions("6.0+") @PluginTargetVersions(gradleVersion = "6.0+")
fun customEntryPointWithoutRunGutter() { fun customEntryPointWithoutRunGutter() {
doTest() doTest()
} }
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin-multiplatform"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
kotlin { kotlin {
targets { targets {
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin-multiplatform"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
kotlin { kotlin {
targets { targets {
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,8 +12,12 @@ apply plugin: "kotlin-multiplatform"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
kotlin { kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
}
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,8 +12,12 @@ apply plugin: "kotlin-multiplatform"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
kotlin { kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
}
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -11,6 +12,7 @@ apply plugin: "kotlin"
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-stdlib"
@@ -2,6 +2,7 @@ buildscript {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:{{kotlin_plugin_version}}"
@@ -4,6 +4,7 @@ version '1.0-SNAPSHOT'
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
@@ -4,6 +4,7 @@ version '1.0-SNAPSHOT'
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
@@ -5,7 +5,7 @@ version '1.0-SNAPSHOT'
buildscript { buildscript {
repositories { repositories {
mavenCentral() {{kotlin_plugin_repositories}}
} }
dependencies { dependencies {
@@ -5,7 +5,7 @@ version '1.0-SNAPSHOT'
buildscript { buildscript {
repositories { repositories {
mavenCentral() {{kotlin_plugin_repositories}}
} }
dependencies { dependencies {
@@ -5,7 +5,7 @@ version '1.0-SNAPSHOT'
buildscript { buildscript {
repositories { repositories {
mavenCentral() {{kotlin_plugin_repositories}}
} }
dependencies { dependencies {
@@ -5,7 +5,7 @@ version '1.0-SNAPSHOT'
buildscript { buildscript {
repositories { repositories {
mavenCentral() {{kotlin_plugin_repositories}}
} }
dependencies { dependencies {
@@ -1,5 +1,5 @@
plugins { plugins {
kotlin("multiplatform") version "1.3.60" kotlin("multiplatform") version "{{kotlin_plugin_version}}"
} }
repositories { repositories {
@@ -1,5 +1,5 @@
plugins { plugins {
kotlin("multiplatform") version "1.3.60" kotlin("multiplatform") version "{{kotlin_plugin_version}}"
} }
repositories { repositories {
@@ -1,5 +1,5 @@
plugins { plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.61' id 'org.jetbrains.kotlin.multiplatform' version '{{kotlin_plugin_version}}'
} }
repositories { repositories {
mavenCentral() mavenCentral()
@@ -1,6 +1,6 @@
plugins { plugins {
id 'java' id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.61' id 'org.jetbrains.kotlin.jvm' version '{{kotlin_plugin_version}}'
id "org.jetbrains.gradle.plugin.idea-ext" version "0.7" id "org.jetbrains.gradle.plugin.idea-ext" version "0.7"
} }
@@ -1,5 +1,5 @@
plugins { plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.61' id 'org.jetbrains.kotlin.multiplatform' version '{{kotlin_plugin_version}}'
} }
repositories { repositories {
mavenCentral() mavenCentral()
@@ -1,5 +1,5 @@
plugins { plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.61' id 'org.jetbrains.kotlin.multiplatform' version '{{kotlin_plugin_version}}'
} }
group 'org.example' group 'org.example'
@@ -1,6 +1,6 @@
plugins { plugins {
id 'java' id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.50' id 'org.jetbrains.kotlin.jvm' version '{{kotlin_plugin_version}}'
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8