简体   繁体   中英

Linking external source folder with name “src” in an eclipse project

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.

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.

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.

It is somewhat ugly, but you can create a hardlink in your filesystem. In the Windows command line, use mklink /H src d:\\path\\to\\external\\src .

I know that the following will hardly be useful, but: Think of a different approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM