Here's code snippet from google/exoplayer - which is written in Groovy buildscript.
// settings.gradle
gradle.ext.exoplayerRoot = 'path/to/exoplayer'
gradle.ext.exoplayerModulePrefix = 'exoplayer-'
apply from: new File(gradle.ext.exoplayerRoot, 'core_settings.gradle')
How can I achieve this using Kotlin DSL?
I couldn't find any useful resources or documents. Any help would be appreciated.
Found a solution after digging a while.
In Groovy, there's dynamic implementation of traits - So even if class A does not implement interface B in the class definition, it may implement it later in the future.
I didn't see Gradle internals so I can't properly explain this, but it seems to work. Hope this helps.
if (gradle is ExtensionAware) {
val extension = gradle as ExtensionAware
extension.extra["exoplayerRoot"] = "path/to/exoplayer"
extension.extra["exoplayerModulePrefix"] = "exoplayer-"
apply(from = File(extension.extra["exoplayerRoot"].toString(), "core_settings.gradle"))
}
For those who uses ExoPlayer, I created an issue for requesting some documents for Kotlin DSL users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With