Awt headless exception

i need simulate keys pressing in my gradle task with Robot class but everytime got exception java.awt.AWTException: headless environment.

Im try set System.setProperty(“java.awt.headless”,“false”) in companion object, init block and plugin apply block and its doesnt work. property = true always. Task runs from terminal powershell in android studio