Skip to content

Commit

Permalink
Better approach to configuring common sources for KotlinJvmCompile task
Browse files Browse the repository at this point in the history
Kotlin's language version 2.0 has a new model to compile common/shared sources which requires more fine-grained task configuration. For language versions lower than 2.0, task configuration is different and all common sources should be set as input.
  • Loading branch information
Tapchicoma committed Feb 14, 2024
1 parent a6c4d67 commit ab64422
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions buildSrc/src/main/kotlin/Java9Modularity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,15 @@ object Java9Modularity {
.find { it.name == "ownModuleName" }
?.get(this) as? Property<String>
ownModuleNameProp?.set(compileTask.kotlinOptions.moduleName)
}

val taskKotlinLanguageVersion = compilerOptions.languageVersion.orElse(KotlinVersion.DEFAULT)
@OptIn(InternalKotlinGradlePluginApi::class)
if (taskKotlinLanguageVersion.get() < KotlinVersion.KOTLIN_2_0) {
// part of work-around for https://youtrack.jetbrains.com/issue/KT-60541
@Suppress("INVISIBLE_MEMBER")
commonSourceSet.from(compileTask.commonSourceSet)
}
@OptIn(InternalKotlinGradlePluginApi::class)
apply {
} else {
multiplatformStructure.refinesEdges.set(compileTask.multiplatformStructure.refinesEdges)
multiplatformStructure.fragments.set(compileTask.multiplatformStructure.fragments)
}
Expand Down

0 comments on commit ab64422

Please sign in to comment.