Can't use console while building with gradle

I want to use in my Java program. returns -1 and that means stream is closed (say not available).
I tried the solution that many ppl suggested: included standardInput =
in my run task, but it didn’t work at all. I’m using IDEA 2016.3 with Gradle 3.1
Don’t blame me for not using latest, I bet the problem persists even if I upgrade. However I’m upgrading to 3.2.1 and if the problem gets solved I will comment here. Till then, please suggest me some solutions.

The problem persists on v3.2.1 also. However running via wrapper from outside of IDEA works good.
Seems this is an integration problem.