Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set global variables in gradle.kts?

My app uses several gradle.kts scripts. I want to set one variable which would be global for everyone.

object Versions{
   val kotlin_version = "1.3.60-eap-25"
}

but it is not resolved:

 classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:$Versions.kotlin_version")
like image 737
Nurseyit Tursunkulov Avatar asked Dec 08 '19 08:12

Nurseyit Tursunkulov


People also ask

What is DSL in Gradle?

Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.

What is EXT in build Gradle?

ext is shorthand for project. ext , and is used to define extra properties for the project object. (It's also possible to define extra properties for many other objects.) When reading an extra property, the ext. is omitted (e.g. println project. springVersion or println springVersion ).


1 Answers

Declared them in gradle.properties file:

kotlin_version = 1.3.60-eap-25

And use it everywhere by findProperty("kotlin_version ")

like image 81
elect Avatar answered Nov 01 '22 23:11

elect