I encountered a problem a few days ago, after using Idr to create a gradle project, the src directory was not automatically generated. Today I will share with you how to solve it.
Table of contents:
1. Create a Gradle project
2. Solve that the src directory is not generated
Question 1: Create a gradle project
First open the ider to create the gradle project
Select gradle on the left side of the new project, select your own jdk version on the right side, check the java project, and click Next
Write the GroupId group name ArtifactId project name and click Next
Here you select the local gradle distribution. Select your own native gradle path in the url below. Click Next to select the project path and complete the creation work.
2: Solve the problem of not generating the src directory
This is the project we just created, and we found that there is no src directory. What should we do? Don't worry, let's solve it
At this time, because the newly created folder is not Source Dir, you need to add a Task task in gradle by yourself
First, open build.gradle and create a Task task
I'll post the code here
task "create-dirs" << { sourceSets*.java.srcDirs*.each { it.mkdirs() } sourceScts*.resources.srcDirs*.each{ it.midirs() }}After adding this task, click Import Changes in the lower right corner
At this time, click Gradle on the right and open other. You will find that the task name we just wrote will be here. Click to execute the task
After the task is executed, the src directory is already generated.
Conclusion: This is the first time I have written a blog. Please comment and point out if there are any shortcomings and will definitely correct it. Make progress for everyone.