We are preparing the migration of our build to Kotlin DSL by replacing all single quote by double quote, adding missing parenthesis in function call and so on.
All is going pretty well except for a transformation of apply plugin: “some plugin” to apply (plugin = “some plugin”) which are located within a closure:< some declarations omitted, buildscript, … >
configure(subprojects.findAll { !sourceless.contains(it.name) }) {
def platform = platformOf(project) if (platform == "common") { // THIS WORKS // apply plugin: "kotlin-platform-common" // apply plugin: "kotlinx-serialization" // BUT THIS DOES NOT apply(plugin = "kotlin-platform-common") apply(plugin = "kotlinx-serialization") dependencies { implementation ("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version") implementation ("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialization_version") testImplementation ("org.jetbrains.kotlin:kotlin-test-common:$kotlin_version") testImplementation ("org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version") } compileKotlinCommon { kotlinOptions.freeCompilerArgs += ["-XXLanguage:+InlineClasses", "-Xuse-experimental=kotlin.Experimental"] } compileTestKotlinCommon { kotlinOptions.freeCompilerArgs += ["-XXLanguage:+InlineClasses", "-Xuse-experimental=kotlin.Experimental"] } } < some more cases for different project types omitted >
}
I get the following error:
Could not set unknown property ‘plugin’ for project ‘someproject’ of type org.gradle.api.Project.
What am I doing wrong and how can I fix this.
Thanks in advance for your help.