I am stuck on converting a common Gradle script to Gradle Kotlin DSL as it applies a custom plugin on its own so that I can’t somehow make it working. What I am exactly trying to achieve this;
android-defaults.gradle (Old way - working)
apply plugin: 'libraryCommonPlugin' -> the custom plugin
android {
defaultConfig {
// other stuff
}
}
And I tried to convert this to Kotlin DSL like so;
android-default.gradle.kts (New way - not working)
plugins {
id("libraryCommonPlugin") -> the custom plugin
}
android {
defaultConfig {
// other stuff
}
}
However, this doesn’t compile at all and I am getting below error;
Expression ‘android’ cannot be invoked as a function. The function
‘invoke()’ is not found
Yes, I am aware of that I don’t apply com.android.application
plugin but when I apply it so then I am getting another error;
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin [id:
‘libraryCommonPlugin’] was not found in any of the following sources:
But I don’t want to have a com.android.application
plugin or whatsoever with it cause both application
and library
scripts will benefit from the above common script like so;
a.gradle.kts
plugins {
id("commons.android-defaults")
id("com.android.library")
id("kotlin-android")
}
dependencies {
}
app.gradle.kts
plugins {
id("commons.android-defaults")
id("com.android.application")
id("kotlin-android")
}
dependencies {
}
Do you have any solution for that particular case?