问题
First, Eclipse is not my native IDE -- I'm barely a n00b with it. I set up a project in a workspace that was actually in the directory of another client's project (I didn't really follow the whole workspace/project thing) and, in fact, now I can't even find the Eclipse workspace file to open it.
What I'd like to do is:
Open my eclipse project (/workspace?) -- I know where all the files are on disk, just not what to open in order to see them in Eclipse -- and
Move my project to a new workspace, which I guess I will put in a generic Eclipse-y place, and have that one workspace reference all my Eclipse projects.
(Is that the right way to do it? Does Eclipse dislike me being a one-project == one-workspace kind of guy?)
Please educate me regarding The Eclipse Way so that I can get back to work writing code.
Thanks!
回答1:
Roughly a workspace (which is a directory) in Eclipse contains:
- configuration (installed JRE, Servers runtimes, code formatting rules, ...)
- one or more projects
You can of course have as many workspaces as you want (but only one can be opened at a time) and a project can also be part of different workspaces.
If you know where your sources are and want to move them to a new workspace here is a possible solution:
- Start Eclipse and when prompted for a workspace choose where you want the workspace to be created (if directory doesn't exist it will be created). For example you can choose C:/Dev/Workspace/.
- If you are not prompted, go to File->Switch workspace->Other
- Once you are in your workspace you can import your exisiting project with File->Import then General->Existing Projects into workspace
- Navigate to the folder containing your project sources, select your project and click finish
I don't know if it's a best practice or not but what I usually do is the following:
- I have one workspace for each of my customer (workspace_cust1, workspace_cust2)
- Each workspace references my commons library projects and add client specific projects
This way each time I change my commons library it's up to date in every workspace.
回答2:
If you want to apply
one workspace = one project
You could to the following:
1) Copy the eclipse desktop shorcut
2) Modify the shortcut by appending "-data workspaceLocation "
来源:https://stackoverflow.com/questions/7180474/how-to-move-an-eclipse-helios-project-to-a-different-workspace