Tests of import with latest gradle plugin are implemented

This commit is contained in:
Andrey Uskov
2019-11-13 20:11:32 +03:00
parent 51590ef1b7
commit e963b71921
43 changed files with 271 additions and 187 deletions
+1
View File
@@ -58,6 +58,7 @@ dependencies {
testRuntime(project(":noarg-ide-plugin"))
testRuntime(project(":kotlin-scripting-idea"))
testRuntime(project(":kotlinx-serialization-ide-plugin"))
testRuntime(project(":kotlin-gradle-plugin"))
// TODO: the order of the plugins matters here, consider avoiding order-dependency
testRuntime(intellijPluginDep("junit"))
testRuntime(intellijPluginDep("testng"))
@@ -329,6 +329,7 @@ class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradl
libraryDependency("Kotlin/Native ${gradleKotlinPluginVersion} - stdlib", DependencyScope.PROVIDED)
libraryDependency("Kotlin/Native ${gradleKotlinPluginVersion} - zlib [linux_x64]", DependencyScope.PROVIDED)
}
module("jvm-on-mpp.hmpp-mod-a.main") {}
module("jvm-on-mpp.hmpp-mod-a.test") {}
}
@@ -812,6 +812,7 @@ class NewMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportin
}
@Test
@PluginTargetVersions(gradleVersion = "4.0+", pluginVersion = "1.3.30+")
fun testJvmWithJava() {
configureByFiles()
importProject(true)
@@ -13,6 +13,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import org.junit.Rule
import org.junit.runners.Parameterized
import java.io.File
import java.util.*
abstract class MultiplePluginVersionGradleImportingTestCase : GradleImportingTestCase() {
@@ -42,13 +43,21 @@ abstract class MultiplePluginVersionGradleImportingTestCase : GradleImportingTes
const val MINIMAL_SUPPORTED_VERSION = "minimal"// minimal supported version
const val LATEST_STABLE_VERSUON = "latest stable"
const val LATEST_SUPPORTED_VERSION = "master"// gradle plugin from current build
private val KOTLIN_GRADLE_PLUGIN_VERSIONS = listOf(MINIMAL_SUPPORTED_VERSION, LATEST_STABLE_VERSUON/*, LATEST_SUPPORTED_VERSION*/)
//should be extended with LATEST_SUPPORTED_VERSION
private val KOTLIN_GRADLE_PLUGIN_VERSIONS = listOf(MINIMAL_SUPPORTED_VERSION, LATEST_STABLE_VERSUON)
private val KOTLIN_GRADLE_PLUGIN_VERSION_DESCRIPTION_TO_VERSION = mapOf(
MINIMAL_SUPPORTED_VERSION to MINIMAL_SUPPORTED_GRADLE_PLUGIN_VERSION,
LATEST_STABLE_VERSUON to LATEST_STABLE_GRADLE_PLUGIN_VERSION,
LATEST_SUPPORTED_VERSION to "master"
LATEST_SUPPORTED_VERSION to readPluginVersion()
)
private fun readPluginVersion() =
File("libraries/tools/kotlin-gradle-plugin/build/libs").listFiles()?.map { it.name }?.firstOrNull { it.contains("-original.jar") }?.replace(
"kotlin-gradle-plugin-",
""
)?.replace("-original.jar", "") ?: "1.3-SNAPSHOT"
@JvmStatic
@Parameterized.Parameters(name = "{index}: Gradle-{0}, KotlinGradlePlugin-{1}")
fun data(): Collection<Array<Any>> {
@@ -63,17 +72,67 @@ abstract class MultiplePluginVersionGradleImportingTestCase : GradleImportingTes
}
}
fun repositories(useKts: Boolean, useMaster: Boolean): String {
val flatDirs = arrayOf(
"libraries/tools/kotlin-gradle-plugin/build/libs",
"libraries/tools/kotlin-gradle-plugin/build/libs",
"prepare/compiler-client-embeddable/build/libs",
"prepare/compiler-embeddable/build/libs",
"libraries/tools/kotlin-gradle-plugin-api/build/libs",
"compiler/compiler-runner/build/libs",
"libraries/tools/kotlin-gradle-plugin-model/build/libs",
"plugins/scripting/scripting-compiler-embeddable/build/libs",
"konan/utils/build/libs"
)
val customRepositories = arrayOf("https://dl.bintray.com/kotlin/kotlin-dev", "http://dl.bintray.com/kotlin/kotlin-eap")
val customMavenRepositories = customRepositories.map { if (useKts) "maven { setUrl(\"$it\") }" else "maven { url '$it' } " }.joinToString("\n")
val baseFolder = File(".").absolutePath.replace("\\", "/")
val quote = if (useKts) '"' else '\''
val flatDirRepositories = if (useMaster)
flatDirs.map { "$quote$baseFolder/$it$quote" }.joinToString(
",\n",
if (useKts) "flatDir { dirs(" else "flatDir { dirs ",
if (useKts) ")}" else "}"
)
else
""
return """
google()
jcenter()
$customMavenRepositories
$flatDirRepositories
""".trimIndent()
}
override fun configureByFiles(properties: Map<String, String>?): List<VirtualFile> {
val unitedProperties = HashMap(properties ?: emptyMap())
unitedProperties["kotlin_plugin_version"] = gradleKotlinPluginVersion
unitedProperties["kotlin_plugin_repositories"] = """
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' }
mavenLocal()
//maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
""".trimIndent()
unitedProperties["kotlin_plugin_repositories"] = repositories(false, gradleKotlinPluginVersionType == LATEST_SUPPORTED_VERSION)
unitedProperties["kts_kotlin_plugin_repositories"] = repositories(true, gradleKotlinPluginVersionType == LATEST_SUPPORTED_VERSION)
unitedProperties["extraPluginDependencies"] = if (gradleKotlinPluginVersionType == LATEST_SUPPORTED_VERSION)
"""
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$gradleKotlinPluginVersion")
classpath("org.jetbrains.kotlin:kotlin-compiler-embeddable:$gradleKotlinPluginVersion")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin-api:$gradleKotlinPluginVersion")
classpath("org.jetbrains.kotlin:kotlin-native-utils:$gradleKotlinPluginVersion")
classpath("org.jetbrains.kotlin:kotlin-compiler-runner:$gradleKotlinPluginVersion")
classpath("org.jetbrains.kotlin:kotlin-compiler-client-embeddable:$gradleKotlinPluginVersion")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin-model:$gradleKotlinPluginVersion")
""".trimIndent()
else
""
unitedProperties["kts_resolution_strategy"] = if (gradleKotlinPluginVersionType == LATEST_SUPPORTED_VERSION)
"""resolutionStrategy {
eachPlugin {
if(requested.id.id == "org.jetbrains.kotlin.multiplatform") {
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:$gradleKotlinPluginVersion")
}
}
}""".trimIndent()
else ""
return super.configureByFiles(unitedProperties)
}
}