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

后端 未结 3 1504
北恋
北恋 2021-01-18 05:09

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

相关标签:
3条回答
  • 2021-01-18 05:23

    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.

    0 讨论(0)
  • 2021-01-18 05:27

    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.

    0 讨论(0)
  • 2021-01-18 05:27

    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.

    0 讨论(0)
提交回复
热议问题