Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private val compilerOptionsMethod by lazy {
}
}

private class KgpImpl(private val dependencyHandler: DependencyHandler, extension: Any, private val providers: ProviderFactory, private val kgpVersion: String) : Kgp {
private class KgpImpl(private val project: Project, private val dependencyHandler: DependencyHandler, extension: Any, private val providers: ProviderFactory, private val kgpVersion: String) : Kgp {
private val kotlinProjectExtension: KotlinProjectExtension = extension as KotlinProjectExtension

override fun javaCompatibility(version: Int) {
Expand Down Expand Up @@ -102,9 +102,7 @@ private class KgpImpl(private val dependencyHandler: DependencyHandler, extensio
* See https://youtrack.jetbrains.com/issue/KT-66755/
*/
val isStdlibDefaultDependencyEnabled =
providers.gradleProperty("kotlin.stdlib.default.dependency")
.map { it.toBooleanStrictOrNull() != false }
.getOrElse(true)
project.findProperty("kotlin.stdlib.default.dependency")?.toString()?.toBooleanStrictOrNull() != false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findProperty is not recommended, see #101 (comment).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've discussed this with @OliverO2 and for now we agreed to set kotlin.stdlib.default.dependency=false in the root project and add the kotlin-stdlib manually where needed.

I've also opened https://youtrack.jetbrains.com/issue/KT-87706/Consider-providing-KGP-API-for-kotlin.stdlib.default.dependencyfalse to improve this in KGP in the long run.


if (isStdlibDefaultDependencyEnabled) {
/**
Expand Down Expand Up @@ -226,7 +224,7 @@ internal fun Project.onKgp(block: (Kgp) -> Unit) {
plugins.withType(KotlinBasePlugin::class.java).configureEach {
if(!hasKgp) {
hasKgp = true
block(KgpImpl(this.dependencies, extensions.getByName("kotlin"), providers, getKotlinPluginVersion()))
block(KgpImpl(this, this.dependencies, extensions.getByName("kotlin"), providers, getKotlinPluginVersion()))
}
}
}