Running with Gradle 8.5 with Java 21 (though I don't think this matters much), it appears when a Gradle task fails the exit code is reported as a success or 0.
At this point, you should see BUILD FAILED. The run: echo $? and you'd see: 0.
If I use the native Gradle wrapper directly with ./gradlew build:
Configuration on demand is an incubating feature.
Calculating task graph as no cached configuration is available for tasks: build
> Task :compileJava FAILED
/Users/misagh/Downloads/demo/src/main/java/com/example/demo/DemoApplication.java:11: error: not a statement
xlvhxjkhvjkxchvkjxchvkjxchvjk
^
/Users/misagh/Downloads/demo/src/main/java/com/example/demo/DemoApplication.java:11: error: ';' expected
xlvhxjkhvjkxchvkjxchvkjxchvjk
^
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --info option to get more log output.
> Run with --scan to get full insights.
At this point, echo $? shows 1 which is the correct exit code.
Running with Gradle 8.5 with Java 21 (though I don't think this matters much), it appears when a Gradle task fails the exit code is reported as a success or
0
.To reproduce:
gm build
BUILD FAILED
. The run:echo $?
and you'd see:0
.If I use the native Gradle wrapper directly with
./gradlew build
:At this point,
echo $?
shows1
which is the correct exit code.