Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking external source folder with name "src" in an eclipse project

Tags:

java

eclipse

This is NOT a question about linking source in eclipse java project

Is it possible to add an external folder named "src" in eclipse as the source folder. The problem here is to keep the external folder name as "src" and not any other name; to do that I tried deleting src and bin folder from the standard eclipse java project and then tried to "Link Source" but that does not work.

Is there any other way I can make this happen?

That is make the Eclipse java project's src actually point to an external folder named "src"? Similar issues with the out put folder "bin" as well.

System Information
OS: Windows 8, 32 bit
Eclipse: 3.7

Thanks.

like image 894
Ayusman Avatar asked Nov 22 '13 13:11

Ayusman


2 Answers

You need to use Eclipse to remove the existing source folder from the project configuration, then delete it from the file system, then you can add the externally linked source folder as "src".

  1. Right-click on the project and bring up "Properties..."

  2. Click on "Java Build Path" and then the "Source" tab to show a list of the source folders on the build path.

  3. Select "yourproject/src" and click the "Remove" button. This will remove it from the project (and the .classpath file).

  4. Come out of it and physically delete the folder.

  5. Go back to that dialog box and this time click "Link source...". It should work now. It works for me.

like image 101
ᴇʟᴇvᴀтᴇ Avatar answered Oct 20 '22 11:10

ᴇʟᴇvᴀтᴇ


To make link with external folder, we need to rename the folder if any folder already exists with same name like "src" or better delete that folder. After that you can make link with the external folder using the anyone of the following method:

Method: 1 - (Make link manually via code):

1. Open the .project file from root folder of your workspace.
2. Include the below code with your file path:
    <linkedResources>
        <link>
            <name>folder_name_list_in_your_project</name>
            <type>2</type>
            <location>folder_path_to_include</location>
        </link>
    </linkedResources>
3. Save the file and refresh the project to include the external folder in your project.

Method: 2 - (Make link manually via UI):

1. Right click the project, select "Build Path -> Configure Build Path".
2. Choose "Source" tab.
3. Click "Link Source" button.
4. Click "Browse" to choose the folder.
5. Enter the folder name in "Folder name" field to list the external name in your project.
6. If you need to add the pattern for include and/or exclude file, click "Next" and enter the pattern. Then click "Finish".
7. Otherwise click "Finish".

It works for me and hope that my steps also help you.

like image 39
Srinivasan.S Avatar answered Oct 20 '22 10:10

Srinivasan.S