문제

An example of .project contains

<linkedResources>
    <link>
        <name>node_lib</name>
        <type>2</type>
        <location>E:/Nodejs/node-v0.10.22/node-v0.10.22/lib</location>
    </link>
</linkedResources>

How to add linked resources programmatically?

org.eclipse.core.resources.IProjectDescription does not have related methods

IProjectDescription

So this Q mentions getLinks() for IProject (JavaDoc has no)
Eclipse Add marker for linked resources

Related to:
Programmatically remove linked files from the project in eclipse

UPDATED: Solved with help of both answers, as they brought understanding of Eclipse terminology (what is what)

Code

   IFolder link = project.getFolder("Link");
   IPath location = new Path("TEMP/folder");
   if (workspace.validateLinkLocation(location).isOK()) {
      link.createLink(location, IResource.NONE, null);
   } else {
      //invalid location, throw an exception or warn user
   }
도움이 되었습니까?

해결책

One of your linked questions actually refers to example code using the createLink method of IFolder.

다른 팁

You use the createLink methods of IFile and IFolder to create linked resources.

For a file you do two steps:

// Get IFile for file
IFile newFile = project.getFile(workspacePath);

// Create the link
newFile.createLink(actualPath, flags, monitor);

and much the same for a folder:

IFolder newFolder = project.getFolder(workspacePath);

newFolder.createLink(actualPath, flags, monitor);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top