Skip to content

Commit 9fc8e7d

Browse files
committed
add changes from review
- use findProperty, no longer warn since gradle has a conventional precendence for regular vs extra property - put properties as in companion - write some documentation on the properties - ran
1 parent 09dfa5f commit 9fc8e7d

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

plugins/dataframe-gradle-plugin/src/main/kotlin/org/jetbrains/dataframe/gradle/ConvenienceSchemaGeneratorPlugin.kt

+18-19
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,33 @@ import org.gradle.api.Plugin
55
import org.gradle.api.Project
66
import org.gradle.api.artifacts.UnknownConfigurationException
77
import org.gradle.kotlin.dsl.getByType
8-
import org.jetbrains.kotlin.gradle.plugin.extraProperties
98
import java.util.Properties
109

1110
@Suppress("unused")
1211
class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
12+
companion object {
13+
/**
14+
* (boolean, default `true`) whether to add KSP plugin
15+
*/
16+
const val PROP_ADD_KSP = "kotlin.dataframe.add.ksp"
17+
18+
/**
19+
* (string, default `null`) comma-delimited list of configurations to add KSP processing to.
20+
* Defaults to guessing configurations based on which kotlin plugin is applied (jvm or multiplatform)
21+
*/
22+
const val PROP_KSP_CONFIGS = "kotlin.dataframe.ksp.configs"
23+
}
24+
1325
override fun apply(target: Project) {
14-
val name = "kotlin.dataframe.add.ksp"
15-
val property = target.findProperty(name)?.toString()
26+
val property = target.findProperty(PROP_ADD_KSP)?.toString()
1627
var addKsp = true
1728

1829
if (property != null) {
1930
if (property.equals("true", ignoreCase = true) || property.equals("false", ignoreCase = true)) {
2031
addKsp = property.toBoolean()
2132
} else {
2233
target.logger.warn(
23-
"Invalid value '$property' for '$name' property. Defaulting to '$addKsp'. Please use 'true' or 'false'.",
34+
"Invalid value '$property' for '$PROP_ADD_KSP' property. Defaulting to '$addKsp'. Please use 'true' or 'false'.",
2435
)
2536
}
2637
}
@@ -47,23 +58,11 @@ class ConvenienceSchemaGeneratorPlugin : Plugin<Project> {
4758
}
4859
}
4960
}
50-
val customConfigsProp = "kotlin.dataframe.ksp.configs"
51-
var overriddenConfigs =
52-
target.properties.get(customConfigsProp)?.let { (it as String)}?.split(",")
53-
if (overriddenConfigs != null) {
54-
overriddenConfigs =
55-
target.extraProperties.get(customConfigsProp)?.let { (it as String)}?.split(",")
56-
} else {
57-
if (customConfigsProp in target.extraProperties.properties) {
58-
target.logger.warn(
59-
"`$customConfigsProp` set as both a regular and an extra property. Only the regular property value is used.",
60-
)
61-
}
62-
}
61+
val overriddenConfigs = target.findProperty(PROP_KSP_CONFIGS)?.let { (it as String) }?.split(",")
6362
val configs = when {
6463
overriddenConfigs != null -> overriddenConfigs
65-
isMultiplatform -> listOf("kspJvm","kspJvmTest")
66-
else -> listOf("ksp","kspTest")
64+
isMultiplatform -> listOf("kspJvm", "kspJvmTest")
65+
else -> listOf("ksp", "kspTest")
6766
}
6867
configs.forEach { cfg ->
6968
try {

0 commit comments

Comments
 (0)