sikri
01/18/2020, 8:13 AMid("org.springframework.boot") version "2.2.3.RELEASE"
kotlin("plugin.spring") version "1.3.61"
kotlin("plugin.allopen") version "1.3.61"
kotlin("multiplatform")
kotlin("kapt")
id("kotlinx-serialization")
apply(plugin = "io.spring.dependency-management")
sourceSets:
sourceSets {
val jvmMain by getting {
kotlin.srcDir("src")
resources.srcDir("resources")
}
dependencies {
implementation(project(":common"))
implementation("org.springframework.boot:spring-boot-starter-web:2.2.3.RELEASE")
implementation("org.springframework.boot:spring-boot-configuration-processor:2.2.3.RELEASE")
configurations["kapt"].dependencies.add(
DefaultExternalModuleDependency(
"org.springframework.boot",
"spring-boot-configuration-processor",
"2.2.3.RELEASE"
)
)
}
}
Idea doesn’t see generated classes (fun main), theefore I’m running via custom run task:
task<JavaExec>("run") {
main = "com.example.mpp.backend.AppRunner"
val jvm by kotlin.targets.getting
val main: KotlinCompilation<KotlinCommonOptions> by jvm.compilations
val runtimeDependencies = (main as KotlinCompilationToRunnableFiles<KotlinCommonOptions>).runtimeDependencyFiles
classpath = files(main.output.allOutputs, runtimeDependencies)
}
But dependencies of Spring don’t see application.yml in this case, and therefore app cannot be startedrusshwolf
01/18/2020, 2:58 PMsikri
01/18/2020, 3:00 PMkotlin("multiplatform")
for non-multiplatform module as simple way with kotlin("jvm")
and just implementation(project(":common"))
, but it did not work - gradle had thought it was an android module (as I have there android target and have enabled android plugin)russhwolf
01/18/2020, 3:08 PMjvm { withJava() }
instead of jvm()
for your target declaration to pick up generated Java source if you have the kotlin("multiplatform")
plugin applied. But if it also wasn’t working with kotlin("jvm")
then it’s probably something else.sikri
01/18/2020, 3:12 PMval server by creating { dependsOn(jvm) }
?sikri
01/18/2020, 3:14 PMsikri
01/18/2020, 3:14 PMrusshwolf
01/18/2020, 3:14 PMrusshwolf
01/18/2020, 3:15 PMsikri
01/18/2020, 3:16 PM