5

So, Eclipse and relative paths...

What I want to achieve is to share the project files with several users, where the exact location of the source can be different for each user.

I.e, the src for project MyProject could be at 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 all.

Heres what I've tried: I set a variable C_TMP in Eclipse pointing to c:\version_control_foo with the idea that user #2 would start up Eclipse with a different setting for the variable. Then I created a linked source folder using the 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>

A change of the variable didn't change anything, which makes sense since it seems the project copied the value of it.

Based on this question I guess I'll be able to do it by having all src folders relative from the workspace location, but that's not really a good solution.

I think maven will be able to handle this by generating Eclipse projects (right?) but I'd like to handle this with pure Eclipse and no special magic scripts.

Edit: This works just like I was hoping if I'm using it to add more libraries. Why won't it work with my source folders?

Edit2: Some clarifications based on comments. The entire project with source folders and files are available in version control. But the actual path to those files are unique for each user. Checking out from version control doesnt involve any kind of copying to a local location that could be defined the same for all.

A linked source folder means I can define it to be relative to a variable. This variable could then be set for each user. Problem is, the value of the variable seems to be copied to the .project file and not go by the value set in Eclipse.

Community
  • 1
  • 1
Fredrik
  • 10,626
  • 6
  • 45
  • 81
  • 2
    I'm confused by the *why* you want to do this. What's wrong with the typical "it's in source control, you check the project out into eclipse's workspace" method that seems to be the standard practice? Are you using a strange source control that doesn't have an Eclipse plugin? Is there some reason you can't tell your co-developers to use the same filepath? – Kane Nov 30 '11 at 15:19
  • 2
    @Kane We use clearcase and the source is then relative to the driveletter clearcase has been mounted to and the name of the clearcase view that the user is using. Both of these can vary between each user. The letter is pretty standard, but the view contains the user id and is unique for everyone. – Fredrik Nov 30 '11 at 15:29
  • 1
    Are you wanting just the source to be different on the different machines, or the entire project directory to be different? I believe you can't do the former (as you've found) but you can do the latter - just get the developers to check out the project into a location of their choosing. It is better to standardise on a location, but some people don't like that. – davidfrancis Nov 30 '11 at 15:33
  • Saw your clearcase comment - interesting. Can you put the entire project in clearcase instead of just the source? Another suggestion would be to use symbolic links under Windows (yes, really!) to link from (say) a d:\myproject\src "link" dir to a different directory on each machine. – davidfrancis Nov 30 '11 at 15:35
  • Added some clarifications in the original question. – Fredrik Dec 01 '11 at 08:47
  • Refer this link for screenshot. http://stackoverflow.com/questions/2565279/android-edit-source-lookup-path/ – Sireesh Yarlagadda Apr 14 '14 at 17:43

1 Answers1

3

Ok, I think I found what I needed. In Eclipse I can set a linked resource that I can use when defining linked source folders. This variable can change and the source folders will then change accordingly. If I can set the linked resource at startup somehow, then I'm all done.

From this question

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

Community
  • 1
  • 1
Fredrik
  • 10,626
  • 6
  • 45
  • 81