I am trying to access `Groovy` extra in my `KTS` s...
# gradle
n
I am trying to access
Groovy
extra in my
KTS
scripts but I couldn’t make it. I have something in my
constants.gradle
Copy code
ext {
    javaTypes = [
            NULL        : "null",
            TRUE        : "true",
            FALSE       : "false",
            BOOLEAN     : "boolean",
            STRING      : "String",
            STRING_ARRAY: "String[]",
            INT         : "int",
            LONG        : "long"
    ]
}
Copy code
val javaTypes by extra

buildConfigField(javaTypes.STRING, constants.HTTP_DEV_URL, asString(Urls.http_dev_url))
And in a KTS script, I am trying to access it like above but I am getting error:
Unresolved reference: javaTypes
Can you help me? Thanks.
m
Usually, you'll need to specify the type of your extra property. Something like:
Copy code
val javaTypes: Map<String, String> by extra
Don't take my word for it though, I never know how Groovy types are mapped to Kotlin/Java ones
n
thanks! Seems instead of
by extra,
by project
worked!
👍 1