Reputation: 11645
I am following the instructions to create a simple IntelliJ Project with Gradle support and the src folder is not created (I guess this is the base of any Java Project) https://www.jetbrains.com/help/idea/getting-started-with-gradle.html
I have no src folder. I am not able to add a new class.
When doing the same without gradle I have the src folder.
UPDATE Adding a module called "src" works, but then I have a module called src and a folder in it called src. But this is a hack. Just bought IntelliJ for 200 bucks and I hope this can be solved in a more professional way :-)
Upvotes: 54
Views: 61093
Reputation: 474
Just right-click on your project directory and choose New -> Directory
.
Select all four to be created.
found the answer here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206806425-Source-Directories-Not-Being-Created-In-New-Project
Upvotes: 36
Reputation: 780
First of all, right-click your project main folder ...
Go to > New > Directory...
After clicking the "Directory" option, this will open a dialog containing available options of "Gradle Source Sets" to add.
You can select what "Gradle Source Sets" you want to add. In my case, I have already added the "src/main/kotlin" (Notice it's not displayed in the options).
Upvotes: 5
Reputation: 29
Add a directory named 'src'. Right click on it and then click Mark Directory as Sources Root.
Upvotes: 2
Reputation: 387
None of the above worked for me. Finally, had to go raw.
gradle init --type java-library
Followed Mkyong's page on gradle init
Then, simply 'Open' project in Intellij. Then updated project settings related to JAVA_HOME and Gradle home (Chances are these were related to my specific installation).
Upvotes: 2
Reputation: 31
If enabling the "Create directories for empty content roots automatically" setting does not show the src directory, check the project structure and try creating and deleting a dummy module.
Upvotes: 3
Reputation: 11645
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".
Upvotes: 66
Reputation: 121
@here A quick fix that worked for me. Once you have created the gradle project as mentioned in the question
Images are attached for clarity.
Open the gradle sidebar on the right hand side.
Check the option "create directories for empty contents roots automatically"
Upvotes: 12