eclipseresourcesvirtual-file

how to create Eclipse virtual file resource


Is there any method to create a virtual file resource in eclipse?

By my definition, such a resource would appear (for Eclipse) to reside at a certain location within the Eclipse project's workspace, but is actually stored somewhere else.

My overall goal is to resolve xml schema documents from project dependencies (jar imports) based on their relative import location. I can accomplish this goal, but now I need a way to make those resolved documents visible in the project folder (within the Eclipse project) relative to the document that imported them without actually writing them to the source folder (they shouldn't be checked-in to source control).

The goal is to allow xml documents to resolve properly in the various eclipse editors, while allowing some of the referenced documents (XSDs and the like) to reside within archives on the project's classpath (or anywhere else such that they're referenced by the project, really).

My initial plan of attack is to create a custom builder plugin which would resolve such documents into virtual resources as the build path was changed. (assuming that such a "virtual file resource" is something that can be created).

Any help is appreciated.


Solution

  • IPath location = new Path(name);
    IFile file = project.getFile(location.lastSegment());
    file.createLink(location, IResource.NONE, null);
    

    seems to be the way to do it; http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresInt_virtual.htm