NOTE: I have just marked this question as a duplicate.
Here is the answer: Console application with Java and gradle
I created a Gradle application that simply receives some input as a String?
. When I try using the "run" task, stringInput
evaluates to null
automatically. I have already tested this with the Kotlin compiler in the terminal, and it works as expected.
Here is the main code below:
package com.s12works.readLineTest
fun main() {
print("Enter text: ")
val stringInput: String? = readLine()
println("You entered: $stringInput")
}
The output from running this application with the run
task:
**> Task :app:run**
Enter text:
You entered: null
How can I stop this? Any help would be appreciated.