Hello,
I am trying to learn how to use the buildSrc folder in Gradle but have a question regarding how one can see the line number where a runtime error occurred in a file in buildSrc. I have the following files:
root/buildSrc/src/main/groovy/MyUtility.groovy
class MyUtility {
static String greet() {
int a = 0/0
return "Hello world!"
}
}
root/build.gradle
apply plugin: 'java'
task showGreeting {
doLast {
MyUtility.greet()
}
}
and a settings.gradle file containing only rootProject.name = 'example5'
.
When I run ./gradlew showGreeting
in my terminal then I get the output
> Task :showGreeting FAILED
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\...\build.gradle' line: 4
* What went wrong:
Execution failed for task ':showGreeting'.
> / by zero
* 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
This message only shows where the error occurred in my build.gradle file, but I would like to see on which line in my MyUtility.groovy file that the error occurred. I know that if I add “–stacktrace” then I get this information but it is very verbose. Is there someway to get an error message similar to
...
* Where:
Build file 'C:\...\buildSrc\src\main\groovy\MyUtility.groovy' line: 3
...
so I can quickly get an idea of where the error occurred?