Introduce explicit plugin versions for MPP builder testing

This commit is contained in:
Mikhail Glukhikh
2018-10-16 14:28:51 +03:00
parent a16318624b
commit 8281416dfa
2 changed files with 41 additions and 9 deletions
@@ -69,10 +69,16 @@ abstract class GradleKotlinFrameworkSupportProvider(
addSupport(buildScriptData, module, rootModel.sdk, true)
}
open fun addSupport(buildScriptData: BuildScriptDataBuilder, module: Module, sdk: Sdk?, specifyPluginVersionIfNeeded: Boolean) {
var kotlinVersion = bundledRuntimeVersion()
open fun addSupport(
buildScriptData: BuildScriptDataBuilder,
module: Module,
sdk: Sdk?,
specifyPluginVersionIfNeeded: Boolean,
explicitPluginVersion: String? = null
) {
var kotlinVersion = explicitPluginVersion ?: bundledRuntimeVersion()
val additionalRepository = getRepositoryForVersion(kotlinVersion)
if (isSnapshot(bundledRuntimeVersion())) {
if (isSnapshot(kotlinVersion)) {
kotlinVersion = LAST_SNAPSHOT_VERSION
}
@@ -157,8 +163,14 @@ open class GradleKotlinJavaFrameworkSupportProvider(
override fun getDependencies(sdk: Sdk?) = listOf(getStdlibArtifactId(sdk, bundledRuntimeVersion()))
override fun addSupport(buildScriptData: BuildScriptDataBuilder, module: Module, sdk: Sdk?, specifyPluginVersionIfNeeded: Boolean) {
super.addSupport(buildScriptData, module, sdk, specifyPluginVersionIfNeeded)
override fun addSupport(
buildScriptData: BuildScriptDataBuilder,
module: Module,
sdk: Sdk?,
specifyPluginVersionIfNeeded: Boolean,
explicitPluginVersion: String?
) {
super.addSupport(buildScriptData, module, sdk, specifyPluginVersionIfNeeded, explicitPluginVersion)
val jvmTarget = getDefaultJvmTarget(sdk, bundledRuntimeVersion())
if (jvmTarget != null) {
val description = jvmTarget.description
@@ -235,8 +247,14 @@ class GradleKotlinMPPJavaFrameworkSupportProvider
override fun getDescription() = "JVM-specific code for a Kotlin multiplatform project"
override fun getTestDependencies() = listOf(MAVEN_TEST_ID, MAVEN_TEST_JUNIT_ID, "junit:junit:4.12")
override fun addSupport(buildScriptData: BuildScriptDataBuilder, module: Module, sdk: Sdk?, specifyPluginVersionIfNeeded: Boolean) {
super.addSupport(buildScriptData, module, sdk, specifyPluginVersionIfNeeded)
override fun addSupport(
buildScriptData: BuildScriptDataBuilder,
module: Module,
sdk: Sdk?,
specifyPluginVersionIfNeeded: Boolean,
explicitPluginVersion: String?
) {
super.addSupport(buildScriptData, module, sdk, specifyPluginVersionIfNeeded, explicitPluginVersion)
val jvmTarget = getDefaultJvmTarget(sdk, bundledRuntimeVersion())
if (jvmTarget != null) {
val description = jvmTarget.description
@@ -26,6 +26,8 @@ import javax.swing.Icon
abstract class KotlinGradleAbstractMultiplatformModuleBuilder(
val mppInApplication: Boolean = false
) : GradleModuleBuilder() {
var explicitPluginVersion: String? = null
override fun getNodeIcon(): Icon = KotlinIcons.MPP
override fun createWizardSteps(wizardContext: WizardContext, modulesProvider: ModulesProvider): Array<ModuleWizardStep> {
@@ -41,7 +43,13 @@ abstract class KotlinGradleAbstractMultiplatformModuleBuilder(
val buildGradle = moduleDir.createChildData(null, "build.gradle")
val builder = BuildScriptDataBuilder(buildGradle)
builder.setupAdditionalDependenciesForApplication()
GradleKotlinMPPFrameworkSupportProvider().addSupport(builder, module, sdk = null, specifyPluginVersionIfNeeded = true)
GradleKotlinMPPFrameworkSupportProvider().addSupport(
builder,
module,
sdk = null,
specifyPluginVersionIfNeeded = true,
explicitPluginVersion = explicitPluginVersion
)
VfsUtil.saveText(buildGradle, builder.buildConfigurationPart() + builder.buildMainPart() + buildMultiPlatformPart())
return moduleDir
}
@@ -75,7 +83,13 @@ abstract class KotlinGradleAbstractMultiplatformModuleBuilder(
enableGradleMetadataPreview(rootDir)
}
val buildGradleText = if (!mppInApplication) {
GradleKotlinMPPFrameworkSupportProvider().addSupport(builder, module, sdk = null, specifyPluginVersionIfNeeded = true)
GradleKotlinMPPFrameworkSupportProvider().addSupport(
builder,
module,
sdk = null,
specifyPluginVersionIfNeeded = true,
explicitPluginVersion = explicitPluginVersion
)
builder.buildConfigurationPart() + builder.buildMainPart() + buildMultiPlatformPart()
} else {
builder.buildConfigurationPart() + builder.buildMainPart()