When creating projects with linked folders (whether manually or using one of C++test available project importers for supported IDEs), the default settings have linked folders specified by absolute path. This may be fine a single desktop user, but it could present a problem if the project is shared by multiple developers who have source code checked out in different root locations. In this case, it is safer to create linked folders using a variable, which you then set to your preference.
Typically, linked folders are added to an existing project via New> Other> General> Folder> Next, selecting the project you want to add a folder to, clicking Advanced button, and then checking Link to a folder on file system. If you wanted to add a folder by absolute path, you’d type in the path, or click Browse to select a folder.
If you wanted to add a folder with a variable for the root location:
- Click Variables in the New Folder dialog.
- Define a variable you’d like to use for the root location of the folder.
- Click New and specify the variable name, and either type in the folder location, or click the Folder button to use the file browser.
- Do one of the following:
- If all the folders you wanted to make available for your project are located directly under the directory specified by your variable, click OK. A linked folder with the name of the variable will be added to your project, with all folders underneath it visible in the Project Navigator.
- If only some specific directories need to be linked, click the Extend button to attach a lower-level directory to the variable you just defined. Using the file browser that opens, select the folder you want, and then click OK. The selected folder will be appended to the variable in the folder location, with the resolved physical location displayed underneath. The folder name will be completed automatically. You can change these values if needed.
- Click Finish. Notice that the linked folder with the specified name was added to the project.
When you check the Properties> Resource on the new folder, the folder location is defined in terms of the root variable (DEMO_DIR in this case), and the resolved path is provided as well:
The directory variables that are specified in the linked folder dialog can be accessed via Window> Preferences> General> Workspace> Linked Resources. They should be set up for each user, and their values are stored in the user’s Eclipse workspace. These variables do not appear in the user’s shell environment on the workstation—and they should not be set there. If you ever need to recreate the workspace, it is easy to re-define these variables when the projects using them are imported into the new workspace.
Note that multiple variables can be used when setting up linked folders to bundle together directories that are in multiple relative locations. Remember to update your preferences with the variable values matching your directory setup.