Skip to content

apply ksp to multiplatform configs in multiplatform modules #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2024
Merged
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 @@ -30,19 +30,27 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
// configure it to depend on symbol-processor-all
target.plugins.whenPluginAdded {
if ("com.google.devtools.ksp" in this.javaClass.packageName) {
val isMultiplatform =
when {
target.plugins.hasPlugin("org.jetbrains.kotlin.jvm") -> false
target.plugins.hasPlugin("org.jetbrains.kotlin.multiplatform") -> true
else -> throw Exception("Kotlin plugin must be applied first so we know whether to use multiplatform configurations or not")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, this exception might be dangerous, since we don't know all possible configurations users might have. We should default to false probably. Fixing it in #655

}
val mainKspCfg = if (isMultiplatform) "kspJvm" else "ksp"
val testKspCfg = if (isMultiplatform) "kspJvmTest" else "kspTest"
try {
target.configurations.getByName("ksp").dependencies.add(
target.configurations.getByName(mainKspCfg).dependencies.add(
target.dependencies.create("org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion")
)
} catch (e: UnknownConfigurationException) {
target.logger.warn("Configuration 'ksp' not found. Please make sure the KSP plugin is applied.")
target.logger.warn("Configuration '$mainKspCfg' not found. Please make sure the KSP plugin is applied.")
}
try {
target.configurations.getByName("kspTest").dependencies.add(
target.configurations.getByName(testKspCfg).dependencies.add(
target.dependencies.create("org.jetbrains.kotlinx.dataframe:symbol-processor-all:$preprocessorVersion")
)
} catch (e: UnknownConfigurationException) {
target.logger.warn("Configuration 'kspTest' not found. Please make sure the KSP plugin is applied.")
target.logger.warn("Configuration '$testKspCfg' not found. Please make sure the KSP plugin is applied.")
}
target.logger.info("Added DataFrame dependency to the KSP plugin.")
target.extensions.getByType<KspExtension>().arg("dataframe.resolutionDir", target.projectDir.absolutePath)
Expand Down