I have very simple task that is defined below - what I am finding is the script get executed perfectly but I always get error.
Could not get unknown property ‘execResult’ for task ‘:myapp:runScriptAndCheckExitCode’ of type org.gradle.api.tasks.Exec.
My shell script exit with code 1 if there was problem, and on sucess exit with code 0. But why am I getting this issue with property execResult. I am using gradle version 8.6
task runScriptAndCheckExitCode(type: Exec) {
String aabPath = "./someaabpath.aab"
commandLine("/bin/sh", "-c", "./../scripts/apk-size-check.sh $aabPath") // Replace with your script and argument
doLast {
if (execResult.exitValue != 0) {
throw new GradleException("Script execution failed with exit code")
}
}
}