alexfacciorusso
11/21/2022, 1:59 PMkspCommonMainMetadata
, it seems not to generate anything…alexfacciorusso
11/21/2022, 2:01 PMcommonMain
, so no need of platform-specific codeJiaxiang
11/21/2022, 6:21 PMalexfacciorusso
11/22/2022, 9:32 AMade
11/22/2022, 9:53 AMade
11/22/2022, 9:55 AMval commonMain by getting {
kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin")
and in the root of the build.gradle.kts
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().all {
if (name != "kspCommonMainKotlinMetadata") {
dependsOn("kspCommonMainKotlinMetadata")
}
}
ade
11/22/2022, 9:56 AMade
11/22/2022, 12:51 PMalexfacciorusso
11/22/2022, 3:18 PMMarc
02/11/2023, 12:02 PMprivate const val TASK_NAME = "kspCommonMainKotlinMetadata"
class KSPPlugin : ProjectPlugin({
apply(plugin = KSP_PLUGIN)
tasks.withType<KotlinCompile<*>>().all {
if (name != TASK_NAME) {
dependsOn(TASK_NAME)
}
}
configure<KotlinMultiplatformExtension> {
sourceSets {
commonMain {
kotlin.srcDir("$buildDir/generated/ksp/metadata/commonMain/kotlin")
}
}
}
})
It compiles and I am able to see the generated code from common (ie: autocomplete, etc). So it's 99% of the way there. But gradle complains:
./gradlew clean build
Configuration on demand is an incubating feature.
Type-safe project accessors is an incubating feature.
> Task :modules:library:inject:api:jvmSourcesJar
Execution optimizations have been disabled for task ':modules:library:inject:api:jvmSourcesJar' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/home/marc/Code/modules/library/inject/api/build/generated/ksp/metadata/commonMain/kotlin'. Reason: Task ':modules:library:inject:api:jvmSourcesJar' uses this output of task ':modules:library:inject:api:kspCommonMainKotlinMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to <https://docs.gradle.org/7.6/userguide/validation_problems.html#implicit_dependency> for more details about this problem.
> Task :modules:library:inject:api:runKtlintCheckOverCommonMainSourceSet
Execution optimizations have been disabled for task ':modules:library:inject:api:runKtlintCheckOverCommonMainSourceSet' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/home/marc/Code/modules/library/inject/api/build/generated/ksp/metadata/commonMain/kotlin'. Reason: Task ':modules:library:inject:api:runKtlintCheckOverCommonMainSourceSet' uses this output of task ':modules:library:inject:api:kspCommonMainKotlinMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to <https://docs.gradle.org/7.6/userguide/validation_problems.html#implicit_dependency> for more details about this problem.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See <https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings>
Execution optimizations have been disabled for 2 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
BUILD SUCCESSFUL in 1s
31 actionable tasks: 22 executed, 1 from cache, 8 up-to-date
Adam S
02/11/2023, 12:15 PMMarc
02/11/2023, 5:25 PMprivate const val TASK_NAME = "kspCommonMainKotlinMetadata"
class KSPPlugin : ProjectPlugin({
apply(plugin = KSP_PLUGIN)
val task = provider { tasks.named(TASK_NAME, KspTaskMetadata::class).get() }
configure<KotlinMultiplatformExtension> {
sourceSets {
commonMain {
val data = task.map { it.destinationDirectory }
kotlin.srcDir(data)
}
}
}
})
Marc
02/11/2023, 5:25 PM* What went wrong:
Circular dependency between the following tasks:
:modules:shared:library:coroutines:core:kspCommonMainKotlinMetadata
\--- :modules:shared:library:coroutines:core:kspCommonMainKotlinMetadata (*)