Bug 559692 - Make it possible to rename / move / copy the workspace directory without issues
Summary: Make it possible to rename / move / copy the workspace directory without issues
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 4.12   Edit
Hardware: PC Linux
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-30 03:59 EST by Giulio Quaresima CLA
Modified: 2024-04-18 08:36 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giulio Quaresima CLA 2020-01-30 03:59:54 EST
When a software organize its work using workspace directories, it is a natural expectation, from the user's point of view, that the workspace directory can be renamed or moved to another location without any negative impact. 

Such an expected behaviour doesn't apply to the Eclipse workspace: if you rename, move or copy your workspace's directory, there are high chances that something goes wrong. In my experience, for example, if you have Maven hierarchical projects in your workspace, and you try to move / rename / copy the workspace, when you open the new one, the child projects appears closed, and if you try to reopen them, you get this error message: 

> "The project description file (.project) for 'foo' is missing.  
> This file contains important information about the project. 
> The project will not function properly until this file is restored.".

Even worse, you cannot restore the workspace easily, because if you try to bring back your workspace to the original location, you find it corrupt and you have to manually reopen each Maven project and cross fingers.

"Grepping" the workspace directory, I found that the ABSOLUTE path of the workspace directory is present inside several files: for example, I have found it inside the .location files in the .metadata directory. I wonder why such locations are not expressed always by the means of relative paths? Using absolute paths inside the workspace make it completely immovable! Copying the workspace is the worst case, because after the copy you have your new workspace pointing to folders of the existing old one!

If the presence of absolute paths is required for some weird reason, it would be a nice enhancement to provide a new "rename / move / copy workspace" tool inside Eclipse.
Comment 1 Paul Pazderski CLA 2020-02-18 17:34:55 EST
Hey Giulio,

I personally agree and had expected less problems from moving a (self containing) workspace. I have checked some of my workspaces and projects and found some with a location file (absolute path) and some without.

It seem to be the case that only projects placed in the root of the workspace (default location / as sibling of the .metadata directory) are described relative.

I have not directly seen a reason for the location URI to be absolute. But I would expect it to be easy or without risk to change. In the end a separate export page might be the more simple fix.

However someone need to implement it and unfortunately no one had expressed interest for this topic yet.

In the meantime the following workaround might satisfy your wish to copy a workspace (although it is not very different to your "copy, fix project and pray" attempt). When switching workspace from within Eclipse you have the option to copy layout, working sets and preferences into the new workspace. After that you can manually copy the projects to the new location and import them in the new workspace.
Comment 2 Giulio Quaresima CLA 2020-02-19 04:55:55 EST
(In reply to Paul Pazderski from comment #1)
> ...
> In the meantime the following workaround might satisfy your wish to copy a
> workspace (although it is not very different to your "copy, fix project and
> pray" attempt). When switching workspace from within Eclipse you have the
> option to copy layout, working sets and preferences into the new workspace.
> After that you can manually copy the projects to the new location and import
> them in the new workspace.

Hi Paul,

thank you for the reply. I tried your workaround and it seems to work like a charm. I followed your instructions, copying three Maven projects with several sub-modules, and they have been imported correctly: I used the "Import" > "Existing Projects into Workspace" function, with the "Search for nested projects" option checked, and I found all the projects in my new workspace, with all their sub-modules, and apparently without any compilation or configuration error.

I also tried to avoid the manual copy of the projects folders into the new workspace, using the "Copy projects into workspace" option, but this way I lost the hierarchical structure of the Maven projects, so your way is better.

A tip: when I was trying your workaround, I discovered that the "option to copy layout, working sets and preferences" is showed only if you switch workspace to a new one which is not present in the list of workspaces already known by Eclipse: you can remove any item from it going to "Switch Workspace" > "Other..." > "Recent Workspaces" > right click > "remove from launcher selection", or editing the $ECLIPSE_HOME/eclipse/configuration/.settings/org.eclipse.ui.ide.prefs file (thanks to https://stackoverflow.com/a/26550841),.
Comment 3 Lars Vogel CLA 2020-02-19 05:58:14 EST
See also Bug 515074 in which we suggest to add the copy option also to the initial workspace selection dialog