Wizard: add resolutionStrategy for mpp library template
This commit is contained in:
+1
@@ -9,6 +9,7 @@ version = '1.0-SNAPSHOT'
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'KOTLIN_REPO' }
|
maven { url 'KOTLIN_REPO' }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -9,6 +9,7 @@ version = "1.0-SNAPSHOT"
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = uri("KOTLIN_REPO") }
|
maven { url = uri("KOTLIN_REPO") }
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -6,6 +6,12 @@ pluginManagement {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url 'KOTLIN_REPO' }
|
maven { url 'KOTLIN_REPO' }
|
||||||
}
|
}
|
||||||
|
resolutionStrategy {
|
||||||
|
eachPlugin {
|
||||||
|
if (requested.id.namespace == 'com.android' || requested.id.name == 'kotlin-android-extensions') {
|
||||||
|
useModule('com.android.tools.build:gradle:4.0.1')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rootProject.name = 'multiplatformMobileLibrary'
|
rootProject.name = 'multiplatformMobileLibrary'
|
||||||
+7
-1
@@ -6,6 +6,12 @@ pluginManagement {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = uri("KOTLIN_REPO") }
|
maven { url = uri("KOTLIN_REPO") }
|
||||||
}
|
}
|
||||||
|
resolutionStrategy {
|
||||||
|
eachPlugin {
|
||||||
|
if (requested.id.namespace == "com.android" || requested.id.name == "kotlin-android-extensions") {
|
||||||
|
useModule("com.android.tools.build:gradle:4.0.1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rootProject.name = "multiplatformMobileLibrary"
|
rootProject.name = "multiplatformMobileLibrary"
|
||||||
+24
@@ -12,6 +12,30 @@ import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
|
|||||||
|
|
||||||
interface PluginManagementIR : GradleIR
|
interface PluginManagementIR : GradleIR
|
||||||
|
|
||||||
|
data class AndroidResolutionStrategyIR(
|
||||||
|
val androidGradlePluginVersion: Version
|
||||||
|
) : PluginManagementIR, FreeIR, SingleIR {
|
||||||
|
override fun GradlePrinter.renderGradle() {
|
||||||
|
sectionCall("resolutionStrategy", needIndent = true) {
|
||||||
|
sectionCall("eachPlugin", needIndent = true) {
|
||||||
|
sectionCall(
|
||||||
|
"if (requested.id.namespace == ${"com.android".quotified} || requested.id.name == ${"kotlin-android-extensions".quotified})",
|
||||||
|
needIndent = true
|
||||||
|
) {
|
||||||
|
call("useModule", forceBrackets = true) {
|
||||||
|
when (dsl) {
|
||||||
|
GradlePrinter.GradleDsl.KOTLIN ->
|
||||||
|
+"com.android.tools.build:gradle:${androidGradlePluginVersion}".quotified
|
||||||
|
GradlePrinter.GradleDsl.GROOVY ->
|
||||||
|
+"com.android.tools.build:gradle:$androidGradlePluginVersion".quotified
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class PluginManagementRepositoryIR(val repositoryIR: RepositoryIR) : PluginManagementIR, RepositoryWrapper {
|
data class PluginManagementRepositoryIR(val repositoryIR: RepositoryIR) : PluginManagementIR, RepositoryWrapper {
|
||||||
override fun GradlePrinter.renderGradle() {
|
override fun GradlePrinter.renderGradle() {
|
||||||
repositoryIR.render(this)
|
repositoryIR.render(this)
|
||||||
|
|||||||
+20
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
|
|||||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardKotlinVersion
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardKotlinVersion
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.AndroidConfigIR
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.AndroidConfigIR
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.irsList
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.library.MavenArtifact
|
import org.jetbrains.kotlin.tools.projectWizard.library.MavenArtifact
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.AndroidPlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.AndroidPlugin
|
||||||
@@ -76,8 +77,13 @@ interface AndroidModuleConfigurator : ModuleConfigurator,
|
|||||||
|
|
||||||
fun Reader.createAndroidPlugin(module: Module): AndroidGradlePlugin
|
fun Reader.createAndroidPlugin(module: Module): AndroidGradlePlugin
|
||||||
|
|
||||||
override fun Reader.createSettingsGradleIRs(module: Module) = buildList<BuildSystemIR> {
|
override fun createSettingsGradleIRs(
|
||||||
+createRepositories(KotlinPlugin.version.propertyValue).map { PluginManagementRepositoryIR(RepositoryIR(it)) }
|
reader: Reader,
|
||||||
|
module: Module,
|
||||||
|
data: ModulesToIrConversionData
|
||||||
|
) = buildList<BuildSystemIR> {
|
||||||
|
+createRepositories(reader { KotlinPlugin.version.propertyValue })
|
||||||
|
.map { PluginManagementRepositoryIR(RepositoryIR(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createModuleIRs(
|
override fun createModuleIRs(
|
||||||
@@ -183,6 +189,18 @@ object AndroidTargetConfigurator : TargetConfigurator,
|
|||||||
GradlePlugin.gradleProperties.addValues("android.useAndroidX" to true)
|
GradlePlugin.gradleProperties.addValues("android.useAndroidX" to true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun createSettingsGradleIRs(
|
||||||
|
reader: Reader,
|
||||||
|
module: Module,
|
||||||
|
data: ModulesToIrConversionData
|
||||||
|
): List<BuildSystemIR> = irsList {
|
||||||
|
+super.createSettingsGradleIRs(reader, module, data)
|
||||||
|
val containsAndroidSingleplatformModule = data.allModules.any { it.configurator is AndroidSinglePlatformModuleConfigurator }
|
||||||
|
if (!containsAndroidSingleplatformModule) {
|
||||||
|
+AndroidResolutionStrategyIR(Versions.GRADLE_PLUGINS.ANDROID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun defaultTestFramework(): KotlinTestFramework = KotlinTestFramework.JUNIT4
|
override fun defaultTestFramework(): KotlinTestFramework = KotlinTestFramework.JUNIT4
|
||||||
|
|
||||||
override fun createModuleIRs(reader: Reader, configurationData: ModulesToIrConversionData, module: Module): List<BuildSystemIR> =
|
override fun createModuleIRs(reader: Reader, configurationData: ModulesToIrConversionData, module: Module): List<BuildSystemIR> =
|
||||||
|
|||||||
+5
-1
@@ -340,5 +340,9 @@ interface ModuleConfigurator : DisplayableSettingItem, EntitiesOwnerDescriptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface GradleModuleConfigurator : ModuleConfigurator {
|
interface GradleModuleConfigurator : ModuleConfigurator {
|
||||||
fun Reader.createSettingsGradleIRs(module: Module): List<BuildSystemIR> = emptyList()
|
fun createSettingsGradleIRs(
|
||||||
|
reader: Reader,
|
||||||
|
module: Module,
|
||||||
|
data: ModulesToIrConversionData
|
||||||
|
): List<BuildSystemIR> = emptyList()
|
||||||
}
|
}
|
||||||
+3
-1
@@ -291,7 +291,9 @@ class ModulesToIRsConverter(
|
|||||||
runArbitraryTask(data, module, modulePath).ensure()
|
runArbitraryTask(data, module, modulePath).ensure()
|
||||||
TemplatesPlugin.addFileTemplates.execute(createTemplates(data, module, modulePath)).ensure()
|
TemplatesPlugin.addFileTemplates.execute(createTemplates(data, module, modulePath)).ensure()
|
||||||
if (this@with is GradleModuleConfigurator) {
|
if (this@with is GradleModuleConfigurator) {
|
||||||
GradlePlugin.settingsGradleFileIRs.addValues(createSettingsGradleIRs(module)).ensure()
|
GradlePlugin.settingsGradleFileIRs.addValues(
|
||||||
|
createSettingsGradleIRs(this@mutateProjectStructureByModuleConfigurator, module, data)
|
||||||
|
).ensure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -398,6 +398,7 @@ object MultiplatformMobileLibraryProjectTemplate : ProjectTemplate() {
|
|||||||
KotlinPlugin.modules.reference withValue listOf(
|
KotlinPlugin.modules.reference withValue listOf(
|
||||||
MultiplatformModule(
|
MultiplatformModule(
|
||||||
"library",
|
"library",
|
||||||
|
template = MobileMppTemplate(),
|
||||||
targets = listOf(
|
targets = listOf(
|
||||||
ModuleType.common.createDefaultTarget(),
|
ModuleType.common.createDefaultTarget(),
|
||||||
Module(
|
Module(
|
||||||
|
|||||||
Reference in New Issue
Block a user