Hi,
I’m trying to make our plugin compatible with Kotlin DSL.
Our current plugin is written in Groovy and the code is available on Github. This plugin is supposed to be integrated on Android project to control some emulators during instrumented tests.
The DSL looks like this:
genymotion {
config {
verbose = true
...
}
devices {
nexus5 {
template "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920"
...
}
anotherNexus5 {
template "Google Nexus 5 - 5.1.0 - API 22 - 1080x1920"
...
}
}
- “genymotion” is the first level extension
- the “config” block is a nested extension
- the “device” block is a
NamedDomainObjectContainer
. For now, we use a Closure to handledevices
but I implemented a version of the plugin usingAction
to be more compatible for this test.
I tried to add our plugin to the hello-android sample:
- I added our plugin on the buildscript dependencies
- I applied our plugin
- I patched the project-schema.json file to add our extension
Then on the build.gradle.kts file, I tried to configure our plugin using the “genymotion” extension. I added the same snippet that I pasted at the beginning of this post (I just added parenthesis on the template
property).
Then, the build fails with this output :
Unresolved reference: config
Unresolved reference: verbose
Unresolved reference: nexus5
Unresolved reference: template
Unresolved reference: anotherNexus5
Unresolved reference: template
Apparently “genymotion” node is correctly accepted. “devices” is also correctly handled (because it is a method declared on the extension class.
But the nested extension and the NamedDomainObjectContainer are raising errors.
Do you have an idea why this is happening?
Does the nested extensions and NamedDomainObjectContainer are currently supported with this language?
EDIT: I just tried to declare productFlavors
on the Android plugin (this is using NamedDomainObjectContainer) and I have the same behaviour. This does not sound good