Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Exit code is reported as a success, 0, even when build fails #54

@mmoayyed

Description

@mmoayyed

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:

  • Download and unpack this
  • Make a compilation error in the source code
  • Run gm build
  • 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions