https://kotlinlang.org logo
Title
d

dharrigan

12/05/2017, 1:22 PM
Hey, with gradle kotlin scripts, one of the things that I find a bit toooo noisy compared to plain groovy gradle scripts, is the necessity to put in
${property("foo")}
inside dependencies definitions, i.e.,
compile("com.google.protobuf:protobuf-java:${property("protobufVersion")}")
I know there is another way of defining the var inside the kts file,
var foo="1.2"
then using
$foo
inside the dependency definition. The latter being more "groovy" like (without the var definition). Is there no shorter way of expressing this?
c

Czar

12/05/2017, 1:57 PM
if you want to use val already defined in gradle.properties you can do this:
val protobufVersion by project

compile("com.google.protobuf:protobuf-java:$protobufVersion")
Which is still more verbose than groovy, but groovy has nonexistent methods interceptors and stuff, it isn't possible in Kotlin.
d

dharrigan

12/05/2017, 2:35 PM
Thank you! 🙂
😉 1