簡體   English   中英

Eclipse插件開發以編程方式在工作空間之外創建項目

[英]Eclipse Plugin Development programmatically create project outside of workspace

有什么方法可以通過編程方式創建項目,但是在磁盤上除工作空間位置之外的其他位置? 我知道,Eclipse工作區只是項目資源的邏輯容器,並且項目可以放置在其他位置(可以更改內置項目模板的位置),但是如何從Java代碼實現呢?

PS:我在ProjectDescription上找到了一些線索,但是我不能以其他方式獲得它,但這是:

        IProjectDescription description = project.getDescription();

問題是,必須已經創建並打開項目,將涉及項目的內容放置在默認位置。

您可以使用以下描述創建一個項目:

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM