Create new Gradle projects --> leads to two projects (project with Name and a project lib)
Create new Gradle projects --> leads to two projects (project with Name and a project lib)
Expected Behavior
Expected one Project with project name.
Current Behavior
Eclipse shows to projects one with the project name (as expected) and one project with name ,,lib'' with the standard directory layout.
There are many questions and discussions since years about this behaviour with instructions to fix it manually.
e.g. --> https://github.com/eclipse/buildship/issues/1077 https://stackoverflow.com/questions/65711292/gradle-build-two-projects-project-with-name-and-a-project-lib https://stackoverflow.com/questions/72802628/why-is-the-source-folder-in-the-lib-folder-in-eclipse-gradle-project https://stackoverflow.com/questions/66005668/eclipse-gradle-wizard-creates-project-with-subfolder-lib [...]
Context
Creating a new gradle project with eclipse works not.. I have in the meantime a script to creates the default folder layout and populate with the necessary files. But there are so many users that have the same issue o i think it is worth to fix it.
Steps to Reproduce
Create new gradle project with -> File -> New Project -> Gradle Project
Your Environment
https://gradle.com/s/ghtzphl5h3v3c
The New Project Gradle dialog creates a Gradle project of the type java-library. In Gradle 7, the project layout has been changed to a lib sibling folder.
Solution: https://github.com/eclipse/buildship/issues/1118
Workaround: In the New Project Gradle dialog choose a Gradle version < 7. After the project has been created, you can change the project type and use a higher Gradle version.
A bit of advice for anyone that has been using Package Explorer in Eclipse as their main explorer window like I was:
If you'd like to use the idiomatic project structure in Eclipse but you're worried about the mess that these lib folders create, use the Project Explorer view instead. It displays all subprojects under the root project in a much more intuitive way. This way you can utilize the improvements brought by the idiomatic structure without worrying about a messy workspace.
You can open the Project Explorer view through Window > Show View > Project Explorer.
I hadn't seen this solution yet in any of the issues linked here and I wasn't keen on dropping back to Gradle version < 7 just to initialize the project "cleanly", so I thought I'd pass along.
The New Project Gradle dialog creates a Gradle project of the type java-library
why would it do that? I'm so tired of always fixing the project structure every time I make a new project. It's almost faster to just make a new java project and copy the structure from an existing one and then add gradle nature. Google tells me since 4 years ago people had issues with that. You select "new gradle project", not "new gradle library project" after all. Personally I cannot see any "improvement" splitting one project in two would bring. But that's just me.
Anyway for other people, the manual fix if you do not want to use an ancient gradle version is:
- Open that lib project
- Copy the build.gradle to your real project and edit it so the plugin is not java-library but java.
- Copy the src folder from the lib to your real project in your file system (eclipse gets a bit confused with nested folders) and refresh in eclipse, or create /src/jmain/java|resources manually.
- Delete the lib project.
- Edit settings.gradle and remove the line include("lib")
- Rightclick your project->gradle->refresh gradle project
Congrats, now you have what the "new gradle project" should have made to begin with, in my opinion.
Workaround: Create a single project using --init-script
https://github.com/eclipse-buildship/buildship/issues/1118#issuecomment-3367932386
