How do I get meaningful error messages from javaexec?

I have this task

task execCucTests() {
      dependsOn compileGroovy, compileTestGroovy
    doLast {
        javaexec {
            main = "cucumber.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output + sourceSets.main.runtimeClasspath
            args = ['-f', 'pretty', '--glue', 'src/test/groovy/com/icd/cucumber/steps', 'src/test/features']
          }
    }
}

It fails with the useless message

Process 'command '/home/dws/bin/jdk1.7.0_21/bin/java'' finished with non-zero exit value 1

I’ve tried --stacktrace, --debug, and --info and all they do is show hundreds of lines of org.gradle… in a stack trace. The error message is the same as above.

I’ve tried changing the main class to a non-existant class to see if it would return ClassNotFound, but it gives the same stupid error message. Ant at least returns a meaningful error message.

What do I have to do to get a useful error message back from Gradle javaexec?

Gradle should provide a way to access the error message. At least log it, please! A different suggestio can found here in the forum

The process stdout and stderr are piped to Gradle’s stdout and stderr by default, so you should see any output from the forked process. So if there is indeed output from the process and you are not seeing it then something deeper is going wrong.

If you run with ‘–info’ it should tell the exact command line invocation it will use to start the process. Grab that and execute it yourself. Do you see output?

This was excatly what I did. I took the command line invocation and executed it directly. Then I am able to see the error message, but it was not logged from Gradle.

What happens if you add this…

javaexec {
  standardOutput = System.out
  errorOutput = System.err
}

?

When I add it, I see the error message. Without it I don’t see it. Maybe the setting above should be the default behaviour?

Thanks for your work.

Sorry, forget it. I need more time to analyse it. There is a gradle log output but it is different than the output when executing it directly. I think I have to solve my particular problem and then check again.