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