Sudoing a test task

In an Exec task (or with project.exec {}), the executable needs to be a executable file (binary, script, etc). So when you try to use “sudo java”, the executable Gradle tries to execute is literally “sudo java”.

To run something as sudo, you want sudo to be the executable and whatever you’re running under sudo to be an argument.