This message was deleted.
# community-support
s
This message was deleted.
j
And the error:
Copy code
FAILURE: Build failed with an exception.

* Where:
Build file '/home/jbrein/data/customers/waitrose/repos/helpers/gradle/test/build.gradle' line: 21

* What went wrong:
A problem occurred evaluating root project 'test'.
> Could not set unknown property 'greeter' for root project 'test' of type org.gradle.api.Project.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at <https://help.gradle.org>

BUILD FAILED in 414ms
v
We do
Actually why should it work?
👍 1
You try to set a property of
project
that does not exist in line 21. And even if that worked, for example because you declare it as local variable by prefixing it with
def
, then line 25 is just a no-op assigning a property to itself.
t
If you meant to assign a variable, then you're missing the
def
declaring it, but then this likely won't work as intended due to scoping:
Copy code
def greeterVar = 'test'

greeting {
    message = 'Hi'
    greeter = greeterVar // naming the variable 'greeter' would read the greeter property of the greeting extension, not the variable
}
j
yeah... was looking at scoping
ahhh!!!!
"naming the variable 'greeter' would read the greeter property of the greeting extension, not the variable"
amazing!
was just wondering why!
v
Actually everything is a bit clearer when using Kotlin DSL, as it is type-safe then and with much better IDE support. At least if you use IntelliJ. 🙂
j
I use VIM... but since I'm doing more gradle intensive I think I'll switch at some point
at least for this
v
Ah, ok, with good-old vim the difference is much smaller of course. 😄 But I'd still prefer Kotlin DSL as errors are much better and usually already at compile-time, not just at runtime. Due to Groovys duck-typing it just cannot error out earlier as anything could be available at runtime.