src folder not created when creating simple Intellij java gradle Project

For Windows the solution is. To go manually into: File -> Settings -> Build, Execution, Deployment -> Gradle -> check the "Create directories for empty content roots automatically".

For Mac the solution is. To go manually into: Intellij IDEA -> Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> check the "Create directories for empty content roots automatically".


@here A quick fix that worked for me. Once you have created the gradle project as mentioned in the question

  • open the gradle sidebar on the right hand side.
  • click settings
  • a new dialog box will appear.
  • In this dialog box check the option "create directories for empty contents roots automatically"
  • then click apply and src folders will be created for you ..

Images are attached for clarity.

Open the gradle sidebar on the right hand side.

Check the option "create directories for empty contents roots automatically"


Just right create on your project directory and choose New -> Directory -> (choose all four to be created: src/main/java, src/main/resource, src/test/java, and src/test/resource) -> enter

right click on project directory

choose the four choices

found the answer here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206806425-Source-Directories-Not-Being-Created-In-New-Project