Custom Gradle task failed

I’ve created a custom Gradle Task in Java, but when I’m running ./gradlew command. It is throwing an error saying

Could not compile settings file ‘/Users/abcd/Documents/android/settings.gradle’.
startup failed:
General error during semantic analysis: Unsupported class file major version 57

I’m not sure what is the exact issue here. Without the custom gradle task file, the command is working fine. Can anyone help here.
My Gradle distribution version is 5.4.1 and JDK version is 13.0.2+8