The overall error thrown is:
Execution failed for task ':compileJava'. Failed to create parent directory '/Users/lokesh/Documents/Projects/MyProject/build/generated' when creating directory '/Users/lokesh/Documents/Projects/MyProject/build/generated/sources/annotationProcessor/java/main'
- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileJava'. Caused by: org.gradle.api.UncheckedIOException: Failed to create parent directory '/Users/lokesh/Documents/Projects/MyProject/build/generated' when creating directory '/Users/lokesh/Documents/Projects/MyProject/build/generated/sources/annotationProcessor/java/main'
It works again after changing the mode of all files under MyProject to chmod 777