Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organize "projects" and "solutions" in Eclipse?

I've been told that an Eclipse workspace is the equivalent of a Visual Studio solution. But I've also been told that people commonly use a single workspace for all their work. Are these apparently conflicting statements correct? If yes, how do we then create and maintain the equivalent of multiple VS solutions in Eclipse?

Secondly, in the case of VS, I check in my solution (.sln) files, too, into source control. Correspondingly, should I or should I not check in the Eclipse workspace's .metadata folder?

like image 278
Frederick The Fool Avatar asked Sep 26 '10 06:09

Frederick The Fool


People also ask

How do I manage multiple projects in Eclipse?

Refresh the Project Explorer. Now go to File > Import... and select "Projects from Folder or Archive" option under the General section. Click on Directory and choose the folder "Test" which is the one that we want to hold multiple java projects. Click on Finish.

How do I organize project Explorer in Eclipse?

The key to make it organized is to open the Package Explorer's View Menu again and enable Top Level Elements > Working Sets. Then the projects are grouped by working set visually in the package explorer. Save this answer.


3 Answers

I don't think, the Eclipse workspace is equivalent to the VS solution. An Eclipse workspace stores a lot of meta-information about projects, their physical location (possibly in or outside of the workspace folder), etc., and even workbench settings. It is not a good idea to upload this information into source control, as it is possible that other developer uses other physical locations for the projects, etc.

There is a similar concept in Eclipse to the solutions (similar, not equivalent): Project sets. It is only a GUI option to group your projects into sets. These sets cannot be executed together, and is only visible in the Project navigator.

Another way is to create multiple workspace folders, and you can use them as an alternative to solutions. The drawback of this approach is, that if you customize the IDE (e.g. by using Preferences, or by defining source control locations), these customizations have to be made in every workspace. This issue can be handled using the Workspace Mechanic tool (I haven't tried it, but it can migrate these settings).

like image 86
Zoltán Ujhelyi Avatar answered Nov 03 '22 01:11

Zoltán Ujhelyi


The main reason why it is better FOR ME to have a separate workspace for a single project is performance and lucidity. With many projects within one workspace, you'd have to close the other ones because of shared classpaths for editor assistance. Editor uses classpaths of all projects for content assist, class hierarchy lookup etc.

Eclipse anticipates that the open projects are related. And when using project managers like Maven, one maven project is usually divided into many little eclipse projects. It's simply a best practice to have a separate workspace for a project. Second reason is, that usually you'd need to import another related project to see how things are done and it would be terrible mess then having it all in one workspace.

You definitely shouldn't commit the .metadata folder into source control. You commit only the projects inside. Because you and others then will check out the project only into their own workspace. But it is a question whether you should commit the .project file, because it's personalized and eclipse version specific and things like project nature (java, spring, maven nature etc.) can anybody set up by himself. .classpath files in the project should be committed to the source control, because they specify classpaths, it would be very time consuming setting it up again.

like image 27
lisak Avatar answered Nov 03 '22 01:11

lisak


You can either group your projects in different workspace or in a particular workspace. Non can be harmful once you manage your settings properly.

like image 40
ellooku Avatar answered Nov 02 '22 23:11

ellooku