简体   繁体   中英

Eclipse Plugin Development programmatically create project outside of workspace

Is there any way to programmatically create project, but in another location on disc than workspace location? I know, that Eclipse workspace is only logical container for project resources, and project can be placed elsewhere (it is possible to change location of built-in project templates), but how to do it from java code?

PS: I found some clue on ProjectDescription, but I can't obtain it in other way but this:

        IProjectDescription description = project.getDescription();

The trouble is, project have to be already created and opened, what involves project is placed in default location.

You create a project using the description with something like:

IWorkspace workspace = ResourcesPlugin.getWorkspace();

// Get a reference to the new project - does NOT create it

IProject project = workspace.getRoot().getProject("project name");

// Create a description for the new project

IProjectDescription description = workspace.newProjectDescription(project.getName());
description.setLocationURI(location);
// TODO fill in other things in the description

// Actually create the project

project.create(description, progressMonitor);

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