eclipse / buildship

The Eclipse Plug-ins for Gradle project.
530 stars 169 forks source link

Create new Gradle projects --> leads to two projects (project with Name and a project lib) #1234

Open bschatz opened 1 year ago

bschatz commented 1 year ago

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

CreateGradleProjectExample CreateGradleProjectExample.gz CreateGradleProjectExample2

howlger commented 1 year ago

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.

TylerGC commented 2 months ago

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.