Skip to content

Commit

Permalink
KotlinMetadataAware: configuration cache fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hsz committed Jun 28, 2024
1 parent eee7155 commit 117633a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import kotlin.io.path.writeText
abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPlatformVersionAware, KotlinMetadataAware, RuntimeAware {

/**
* Report directory where the verification result will be stored.
* Report the directory where the verification result will be stored.
*/
@get:OutputDirectory
abstract val reportDirectory: DirectoryProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package org.jetbrains.intellij.platform.gradle.tasks.aware

import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal

/**
Expand All @@ -14,9 +15,15 @@ interface KotlinMetadataAware {
/**
* Indicates that the Kotlin Gradle Plugin is loaded and available.
*/
@get:Internal
@get:Input
val kotlinPluginAvailable: Property<Boolean>

/**
* This variable represents whether the Kotlin Coroutines library is added explicitly to the project dependencies.
*/
@get:Input
val kotlinxCoroutinesLibraryPresent: Property<Boolean>

/**
* The `apiVersion` property value of `compileKotlin.kotlinOptions` defined in the build script.
*/
Expand Down Expand Up @@ -45,11 +52,5 @@ interface KotlinMetadataAware {
* `kotlin.stdlib.default.dependency` property value defined in the `gradle.properties` file.
*/
@get:Internal
val kotlinStdlibDefaultDependency: Property<Boolean>

/**
* This variable represents whether the Kotlin Coroutines library is added explicitly to the project dependencies.
*/
@get:Internal
val kotlinxCoroutinesLibraryPresent: Property<Boolean>
val kotlinStdlibDefaultDependency: Property<Boolean?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ internal fun <T : Task> Project.preconfigureTask(task: T) {
}

if (this is KotlinMetadataAware) {
kotlinPluginAvailable.convention(false)
kotlinxCoroutinesLibraryPresent.convention(project.provider {
listOf(
Configurations.External.IMPLEMENTATION,
Expand All @@ -242,15 +243,14 @@ internal fun <T : Task> Project.preconfigureTask(task: T) {
}
})

kotlinPluginAvailable.convention(project.provider {
project.pluginManager.hasPlugin(Plugins.External.KOTLIN)
})
project.pluginManager.withPlugin(Plugins.External.KOTLIN) {
val kotlinOptionsProvider = project.tasks.named(Tasks.External.COMPILE_KOTLIN).map {
it.withGroovyBuilder { getProperty("kotlinOptions") }
.withGroovyBuilder { getProperty("options") }
}

kotlinPluginAvailable.convention(true)

kotlinJvmTarget.convention(kotlinOptionsProvider.flatMap {
it.withGroovyBuilder { getProperty("jvmTarget") as Property<*> }
.map { jvmTarget -> jvmTarget.withGroovyBuilder { getProperty("target") } }
Expand All @@ -276,6 +276,14 @@ internal fun <T : Task> Project.preconfigureTask(task: T) {
.map { it.toBoolean() }
)
}

inputs.properties(
"kotlinJvmTarget" to project.provider { kotlinJvmTarget.orNull.toString() },
"kotlinApiVersion" to project.provider { kotlinApiVersion.orNull.toString() },
"kotlinLanguageVersion" to project.provider { kotlinLanguageVersion.orNull.toString() },
"kotlinVersion" to project.provider { kotlinVersion.orNull.toString() },
"kotlinStdlibDefaultDependency" to project.provider { kotlinStdlibDefaultDependency.orNull.toString() },
)
}
}
}
Expand Down

0 comments on commit 117633a

Please sign in to comment.