Gradle silently stops execution without displaying errors

(satswati) #1

I have been using following code in init.gradle

useLogger(new CustomEventLogger())
  class CustomEventLogger extends BuildAdapter implements TaskExecutionListener {
      public void beforeExecute(Task task) {
        println "[$]"
      public void afterExecute(Task task, TaskState state) {
        println "$state.failure.message"
          public void buildFinished(BuildResult result) {
        println 'build completed'

I have two tasks defined in build.gradle

First task code is to run task without errors whereas second task code is to fail.

After running “task1”, “task 2” never gets executed.

Because after executing task 1, gradle executes “afterExecute” method of CustomEventLogger class. This method tries to access state.failure.message whereas as task1 is successfully executed it doesnt have failure and so message attribute. Because of this task2 never gets invoked. Gradle displays build successful messages whereas task 2 is never invoked.

These silent errors should be displayed properly in the gradle build output

(Luke Daley) #2

It’s hard to diagnose this without more info.

Any chance that you could push an example project somewhere that exhibits this problem that I can play with?