Declare and use project.extmyFunction in Kotlin

I’m rewiring my plugin from groovy to Kotlin.
I’m often using this code in Groovy

    project.ext.isSnapshotBuild = {
        return versionProvider.get().isSnapshotBuild()

    project.ext.isWindows = {
        return Os.isFamily(Os.FAMILY_WINDOWS)

    project.ext.isIDEBuild = {
        return (boolean)['android.injected.invoked.from.ide']

How rewrite the same logic to Kolin. I need to keep compatibility with project which still using groovy based build script.

And what is currently the suggested way how to do it?
I was thinking about project.extensions.create where I can put my object with my methods which can be called easily from Kotlin build script. It is a good way?

I did not found a way how to extend Project class in the way that will be available in the project which using my plugin. Inside of plugin I have this

fun Project.isIDEBuild(): Boolean {
    return this.hasProperty("android.injected.invoked.from.ide")

but it is not working the project which using my plugin.

So, this is a correct way how to do it in a way compatible with Groovy build scripts

project.extra["isIDEBuild"] = KotlinClosure0({

For Kotlin based build script is the best way to user Kotlin extension function or property like

val Project.isIDEBuild: Boolean
    get() {
        return this.hasProperty("android.injected.invoked.from.ide")