5

I want to log all console output from my gradle script to log file:

gradle test 2>&1 | tee -a gradle.log  

But my gradle script prompts param from user:

task test << {
        System.console().readLine("Enter:").toString()
}

As a result, I have a NullPointerException:

Execution failed for task ':test'. Cannot invoke method readLine() on null object

May be somebody know a solution or workaround for this situation?

Anthony Tsivarev
  • 881
  • 3
  • 13
  • 25
  • Is this at all related to logging the console output? From what I remember, `System.console()` may not be available in a Gradle build script, at least not when using the Gradle daemon. – Peter Niederwieser Nov 27 '14 at 12:35
  • Possible duplicate of [Gradle build null console object](http://stackoverflow.com/questions/19487576/gradle-build-null-console-object) – Michael Schaefers Jan 30 '16 at 20:43

1 Answers1

0

What about:

yes <desired input> | gradle test 2>&1 | tee -a gradle.log 

yes just repeditively echos whatever it's argument is to stdout

Matthew Jones
  • 944
  • 9
  • 17