Relative source paths in Eclipse

So, Eclipse and relative paths ...

I want to achieve sharing of project files by several users, where the exact location of the source may differ for each user.

Ie, src for the MyProject project can be in c:\version_control_foo\MyProject\src or c:\version_control_bar\MyProject\src or even X:\foobar\MyProject\src , and the same project should work for everyone.

Here's what I tried: I set the C_TMP variable in Eclipse, pointing to c:\version_control_foo , with the idea that user # 2 will start Eclipse with a different setting for the variable. Then I created a linked source folder using a variable.

This created this entry in my .project file:

 <linkedResources> <link> <name>C_TMP</name> <type>2</type> <locationURI>C_TMP</locationURI> </link> </linkedResources> <variableList> <variable> <name>C_TMP</name> <value>file:/C:/version_control_foo</value> </variable> </variableList> 

Changing a variable did not change anything, which makes sense, since it seems that the project copied its value.

Based on this question , I think I can do this by having all the src folders relative to the location of the workspace, but this is not a good solution.

I think maven will be able to handle this by creating Eclipse projects (right?), But I would like to handle this with pure Eclipse and special magic scripts.

Edit: This works the same as I had hoped if I use it to add additional libraries. Why won't it work with my source folders?

Edit2: Some comments based commentary. The entire project with source folders and files is available in version control. But the actual path to these files is unique to each user. Checking out of version control does not imply any copying to a local location that can be determined to be the same for everyone.

A linked source folder means that I can define it relative to a variable. Then this variable can be set for each user. The problem is that the value of the variable seems to be copied to the .project file, and not to the value set in Eclipse.

+4
source share
1 answer

Ok, I think I found what I need. In Eclipse, I can set up a linked resource that I can use when defining linked source folders. This variable may change, and the source folders will change accordingly. If I can set the related resource at startup in some way, then I will do everything.

Of this question

Go to Window > Preferences , then General > Workspace > Linked Resources and define your folder here. Then you can use a specific variable in the project.

+3
source

Source: https://habr.com/ru/post/1383892/


All Articles