Wizard: update compose templates
#KT-43032 fixed
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.4.0"
|
kotlin("jvm") version "1.4.0"
|
||||||
id("org.jetbrains.compose") version "0.1.0-build63"
|
id("org.jetbrains.compose") version "0.1.0-dev106"
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(compose.desktop.all)
|
implementation(compose.desktop.currentOs)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>() {
|
tasks.withType<KotlinCompile>() {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("org.jetbrains.compose") version "0.1.0-build63"
|
id("org.jetbrains.compose") version "0.1.0-dev106"
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ import org.jetbrains.compose.compose
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
id("org.jetbrains.compose") version "0.1.0-build63"
|
id("org.jetbrains.compose") version "0.1.0-dev106"
|
||||||
id("com.android.library")
|
id("com.android.library")
|
||||||
id("kotlin-android-extensions")
|
id("kotlin-android-extensions")
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ kotlin {
|
|||||||
android()
|
android()
|
||||||
jvm("desktop") {
|
jvm("desktop") {
|
||||||
compilations.all {
|
compilations.all {
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
kotlinOptions.jvmTarget = "11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
+17
-10
@@ -1,22 +1,29 @@
|
|||||||
import org.jetbrains.compose.compose
|
import org.jetbrains.compose.compose
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm")
|
kotlin("multiplatform")
|
||||||
id("org.jetbrains.compose") version "0.1.0-build63"
|
id("org.jetbrains.compose") version "0.1.0-dev106"
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "me.user"
|
group = "me.user"
|
||||||
version = "1.0-SNAPSHOT"
|
version = "1.0-SNAPSHOT"
|
||||||
|
|
||||||
dependencies {
|
kotlin {
|
||||||
implementation(project(":common"))
|
jvm {
|
||||||
implementation(compose.desktop.all)
|
compilations.all {
|
||||||
}
|
kotlinOptions.jvmTarget = "11"
|
||||||
|
}
|
||||||
tasks.withType<KotlinCompile>() {
|
}
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
sourceSets {
|
||||||
|
val jvmMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":common"))
|
||||||
|
implementation(compose.desktop.currentOs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jvmTest by getting
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ object Versions {
|
|||||||
val KTOR = version("1.4.0")
|
val KTOR = version("1.4.0")
|
||||||
val JUNIT = version("4.13")
|
val JUNIT = version("4.13")
|
||||||
val JUNIT5 = version("5.6.0")
|
val JUNIT5 = version("5.6.0")
|
||||||
val JETBRAINS_COMPOSE = version("0.1.0-build63")
|
val JETBRAINS_COMPOSE = version("0.1.0-dev106")
|
||||||
|
|
||||||
val KOTLIN_VERSION_FOR_COMPOSE = version("1.4.0")
|
val KOTLIN_VERSION_FOR_COMPOSE = version("1.4.0")
|
||||||
|
|
||||||
|
|||||||
+63
-55
@@ -144,21 +144,7 @@ class ModulesToIRsConverter(
|
|||||||
state: ModulesToIrsState
|
state: ModulesToIrsState
|
||||||
): TaskResult<List<BuildFileIR>> = computeM {
|
): TaskResult<List<BuildFileIR>> = computeM {
|
||||||
val modulePath = calculatePathForModule(module, state.parentPath)
|
val modulePath = calculatePathForModule(module, state.parentPath)
|
||||||
val (moduleDependencies) = forModuleEachDependency(module) { from, to, dependencyType ->
|
val (moduleDependencies) = createModuleDependencies(module)
|
||||||
with(dependencyType) {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
with(unsafeSettingWriter) {
|
|
||||||
runArbitraryTask(
|
|
||||||
module,
|
|
||||||
to,
|
|
||||||
to.path.considerSingleRootModuleMode(data.isSingleRootModuleMode).asPath(),
|
|
||||||
data
|
|
||||||
).ensure()
|
|
||||||
}
|
|
||||||
irsToAddToModules.getOrPut(to) { mutableListOf() } += createToIRs(module, to, data).get()
|
|
||||||
createDependencyIrs(module, to, data).asSuccess()
|
|
||||||
}
|
|
||||||
}.map { it.flatten() }
|
|
||||||
mutateProjectStructureByModuleConfigurator(module, modulePath)
|
mutateProjectStructureByModuleConfigurator(module, modulePath)
|
||||||
val buildFileIR = run {
|
val buildFileIR = run {
|
||||||
if (!configurator.needCreateBuildFile) return@run null
|
if (!configurator.needCreateBuildFile) return@run null
|
||||||
@@ -214,50 +200,69 @@ class ModulesToIRsConverter(
|
|||||||
private fun Writer.createMultiplatformModule(
|
private fun Writer.createMultiplatformModule(
|
||||||
module: Module,
|
module: Module,
|
||||||
state: ModulesToIrsState
|
state: ModulesToIrsState
|
||||||
): TaskResult<List<BuildFileIR>> = with(data) {
|
): TaskResult<List<BuildFileIR>> = compute {
|
||||||
val modulePath = calculatePathForModule(module, state.parentPath)
|
with(data) {
|
||||||
mutateProjectStructureByModuleConfigurator(module, modulePath)
|
val modulePath = calculatePathForModule(module, state.parentPath)
|
||||||
val targetIrs = module.subModules.flatMap { subModule ->
|
mutateProjectStructureByModuleConfigurator(module, modulePath)
|
||||||
with(subModule.configurator as TargetConfigurator) { createTargetIrs(subModule) }
|
val targetIrs = module.subModules.flatMap { subModule ->
|
||||||
}
|
with(subModule.configurator as TargetConfigurator) { createTargetIrs(subModule) }
|
||||||
|
}
|
||||||
|
|
||||||
val targetModuleIrs = module.subModules.map { target ->
|
val (targetModuleIrs) = module.subModules.mapSequence { target ->
|
||||||
createTargetModule(target, modulePath)
|
createTargetModule(target, modulePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
return BuildFileIR(
|
BuildFileIR(
|
||||||
projectName,
|
projectName,
|
||||||
modulePath,
|
modulePath,
|
||||||
MultiplatformModulesStructureIR(
|
MultiplatformModulesStructureIR(
|
||||||
targetIrs,
|
targetIrs,
|
||||||
FakeMultiplatformModuleIR(
|
FakeMultiplatformModuleIR(
|
||||||
module.name,
|
module.name,
|
||||||
modulePath,
|
modulePath,
|
||||||
module.template,
|
module.template,
|
||||||
|
targetModuleIrs,
|
||||||
|
module,
|
||||||
|
),
|
||||||
targetModuleIrs,
|
targetModuleIrs,
|
||||||
module,
|
persistentListOf()
|
||||||
),
|
),
|
||||||
targetModuleIrs,
|
module.subModules + module,
|
||||||
persistentListOf()
|
pomIr,
|
||||||
),
|
isRoot = false,
|
||||||
module.subModules + module,
|
renderPomIr = StructurePlugin.renderPomIR.settingValue,
|
||||||
pomIr,
|
buildPersistenceList {
|
||||||
isRoot = false,
|
+createBuildFileIRs(module, state)
|
||||||
renderPomIr = StructurePlugin.renderPomIR.settingValue,
|
module.subModules.forEach { +createBuildFileIRs(it, state) }
|
||||||
buildPersistenceList {
|
}
|
||||||
+createBuildFileIRs(module, state)
|
).also { buildFile ->
|
||||||
module.subModules.forEach { +createBuildFileIRs(it, state) }
|
moduleToBuildFile[module] = buildFile
|
||||||
}
|
module.subModules.forEach { subModule ->
|
||||||
).also { buildFile ->
|
moduleToBuildFile[subModule] = buildFile
|
||||||
moduleToBuildFile[module] = buildFile
|
}
|
||||||
module.subModules.forEach { subModule ->
|
}.asSingletonList()
|
||||||
moduleToBuildFile[subModule] = buildFile
|
}
|
||||||
}
|
|
||||||
}.asSingletonList().asSuccess()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Writer.createTargetModule(target: Module, modulePath: Path): MultiplatformModuleIR {
|
private fun Writer.createModuleDependencies(module: Module): TaskResult<List<BuildSystemIR>> =
|
||||||
|
forModuleEachDependency(module) { from, to, dependencyType ->
|
||||||
|
with(dependencyType) {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
unsafeSettingWriter {
|
||||||
|
runArbitraryTask(
|
||||||
|
module,
|
||||||
|
to,
|
||||||
|
to.path.considerSingleRootModuleMode(data.isSingleRootModuleMode).asPath(),
|
||||||
|
data
|
||||||
|
).ensure()
|
||||||
|
}
|
||||||
|
irsToAddToModules.getOrPut(to) { mutableListOf() } += createToIRs(module, to, data).get()
|
||||||
|
createDependencyIrs(module, to, data).asSuccess()
|
||||||
|
}
|
||||||
|
}.map { it.flatten() }
|
||||||
|
|
||||||
|
private fun Writer.createTargetModule(target: Module, modulePath: Path): TaskResult<MultiplatformModuleIR> = compute {
|
||||||
|
val (moduleDependencies) = createModuleDependencies(target)
|
||||||
mutateProjectStructureByModuleConfigurator(target, modulePath)
|
mutateProjectStructureByModuleConfigurator(target, modulePath)
|
||||||
val sourcesetss = target.sourcesets.map { sourceset ->
|
val sourcesetss = target.sourcesets.map { sourceset ->
|
||||||
val sourcesetName = target.name + sourceset.sourcesetType.name.capitalize()
|
val sourcesetName = target.name + sourceset.sourcesetType.name.capitalize()
|
||||||
@@ -269,10 +274,13 @@ class ModulesToIRsConverter(
|
|||||||
sourceset
|
sourceset
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return MultiplatformModuleIR(
|
MultiplatformModuleIR(
|
||||||
target.name,
|
target.name,
|
||||||
modulePath,
|
modulePath,
|
||||||
with(target.configurator) { createModuleIRs(this@createTargetModule, data, target) }.toPersistentList(),
|
buildPersistenceList {
|
||||||
|
+moduleDependencies
|
||||||
|
with(target.configurator) { +createModuleIRs(this@createTargetModule, data, target) }
|
||||||
|
},
|
||||||
target.template,
|
target.template,
|
||||||
target,
|
target,
|
||||||
sourcesetss
|
sourcesetss
|
||||||
|
|||||||
+17
-7
@@ -515,6 +515,7 @@ object ComposeMultiplatformApplicationProjectTemplate : ProjectTemplate() {
|
|||||||
subModules = emptyList()
|
subModules = emptyList()
|
||||||
).withConfiguratorSettings(JvmTargetConfigurator) {
|
).withConfiguratorSettings(JvmTargetConfigurator) {
|
||||||
ModuleConfiguratorWithTests.testFramework withValue KotlinTestFramework.NONE
|
ModuleConfiguratorWithTests.testFramework withValue KotlinTestFramework.NONE
|
||||||
|
JvmModuleConfigurator.targetJvmVersion withValue TargetJvmVersion.JVM_11
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -530,14 +531,23 @@ object ComposeMultiplatformApplicationProjectTemplate : ProjectTemplate() {
|
|||||||
}
|
}
|
||||||
+Module(
|
+Module(
|
||||||
"desktop",
|
"desktop",
|
||||||
JvmSinglePlatformModuleConfigurator,
|
MppModuleConfigurator,
|
||||||
template = ComposeJvmDesktopTemplate(),
|
template = null,
|
||||||
sourcesets = createDefaultSourcesets(),
|
sourcesets = createDefaultSourcesets(),
|
||||||
subModules = emptyList(),
|
subModules = listOf(
|
||||||
dependencies = mutableListOf(ModuleReference.ByModule(common))
|
Module(
|
||||||
).withConfiguratorSettings(JvmSinglePlatformModuleConfigurator) {
|
"jvm",
|
||||||
ModuleConfiguratorWithTests.testFramework withValue KotlinTestFramework.NONE
|
JvmTargetConfigurator,
|
||||||
}
|
template = ComposeJvmDesktopTemplate(),
|
||||||
|
sourcesets = createDefaultSourcesets(),
|
||||||
|
subModules = emptyList(),
|
||||||
|
dependencies = mutableListOf(ModuleReference.ByModule(common))
|
||||||
|
).withConfiguratorSettings(JvmTargetConfigurator) {
|
||||||
|
ModuleConfiguratorWithTests.testFramework withValue KotlinTestFramework.NONE
|
||||||
|
JvmModuleConfigurator.targetJvmVersion withValue TargetJvmVersion.JVM_11
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
+common
|
+common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
@@ -86,6 +86,14 @@ sealed class ModuleDependencyType(
|
|||||||
to = MppModuleConfigurator::class
|
to = MppModuleConfigurator::class
|
||||||
)
|
)
|
||||||
|
|
||||||
|
object JVMTargetToMPP : ModuleDependencyType(
|
||||||
|
from = JvmTargetConfigurator::class,
|
||||||
|
to = MppModuleConfigurator::class
|
||||||
|
) {
|
||||||
|
override fun additionalAcceptanceChecker(from: Module, to: Module): Boolean =
|
||||||
|
from !in to.subModules
|
||||||
|
}
|
||||||
|
|
||||||
object IOSToMppSinglePlatformToMPP : ModuleDependencyType(
|
object IOSToMppSinglePlatformToMPP : ModuleDependencyType(
|
||||||
from = IOSSinglePlatformModuleConfigurator::class,
|
from = IOSSinglePlatformModuleConfigurator::class,
|
||||||
to = MppModuleConfigurator::class
|
to = MppModuleConfigurator::class
|
||||||
@@ -184,6 +192,7 @@ sealed class ModuleDependencyType(
|
|||||||
JVMSinglePlatformToJVMSinglePlatform,
|
JVMSinglePlatformToJVMSinglePlatform,
|
||||||
JVMSinglePlatformToMPP,
|
JVMSinglePlatformToMPP,
|
||||||
AndroidSinglePlatformToMPP,
|
AndroidSinglePlatformToMPP,
|
||||||
|
JVMTargetToMPP,
|
||||||
IOSToMppSinglePlatformToMPP
|
IOSToMppSinglePlatformToMPP
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -38,6 +38,7 @@ class ComposeJvmDesktopTemplate : Template() {
|
|||||||
|
|
||||||
override fun isApplicableTo(reader: Reader, module: Module): Boolean =
|
override fun isApplicableTo(reader: Reader, module: Module): Boolean =
|
||||||
module.kind == ModuleKind.singleplatformJvm
|
module.kind == ModuleKind.singleplatformJvm
|
||||||
|
|| module.kind == ModuleKind.target
|
||||||
|
|
||||||
override fun Writer.getIrsToAddToBuildFile(
|
override fun Writer.getIrsToAddToBuildFile(
|
||||||
module: ModuleIR
|
module: ModuleIR
|
||||||
@@ -51,7 +52,7 @@ class ComposeJvmDesktopTemplate : Template() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun Writer.getRequiredLibraries(module: ModuleIR): List<DependencyIR> = listOf(
|
override fun Writer.getRequiredLibraries(module: ModuleIR): List<DependencyIR> = listOf(
|
||||||
CustomGradleDependencyDependencyIR("compose.desktop.all", dependencyType = DependencyType.MAIN, DependencyKind.implementation)
|
CustomGradleDependencyDependencyIR("compose.desktop.currentOs", dependencyType = DependencyType.MAIN, DependencyKind.implementation)
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun Writer.runArbitratyTask(module: ModuleIR): TaskResult<Unit> =
|
override fun Writer.runArbitratyTask(module: ModuleIR): TaskResult<Unit> =
|
||||||
|
|||||||
Reference in New Issue
Block a user