I am testing a few basics of gradle. This is what my gradle file "build.gradle" looked like:
task hello { doLast { println 'Hello World!' } }
This results in the following error:
D:\DevAreas\learn-gradle>gradle -q hello FAILURE: Build failed with an exception. * Where: Build file 'D:\DevAreas\learn-gradle\build.gradle' line: 2 * What went wrong: Could not compile build file 'D:\DevAreas\learn-gradle\build.gradle'. > startup failed: build file 'D:\DevAreas\learn-gradle\build.gradle': 2: Ambiguous expression could be a parameterle ss closure expression, an isolated open code block, or it may continue a previous statement; solution: Add an explicit parameter list, eg {it -> ...}, or force it to be treated as an open block by giving it a label, eg L:{...}, and also either remove the previous newline, or add an exp licit semicolon ';' @ line 2, column 1. { ^ 1 error * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more l og output.
If I make a small modification to the assembly file, for example,
[Please note that I have moved the bracket from the second line to the first line]
task hello{ doLast { println 'Hello World!' } }
I see the conclusion
Hello World!
no problem.
Is brace such a big problem in gradle? What did I do wrong by putting the brackets on the second line?
source share