Eclipse插件開發 獲取Workspace下所有的項目
在開發Eclipse插件時候,發現需要獲取到Workspace下所有的項目。決定通過ResourcePlugin來獲取。
1、導入ResourcePlugin所在的Jar包org.eclipse.core.resources_3.8.101.v20130717-0806.jar進lib目錄。
2、配置plugin.xml的Runtime選項卡,在Classpath中增加剛才在lib目錄上加進來的jar包.
3、配置plugin.xml的Dependencies選項卡,另入依賴org.eclipse.core.resources.source。
4、在代碼中使用
ResourcesPlugin.getWorkspace().getRoot().getProjects();
5、注意:
如果沒配置第2步,會報ResourcePlugin ClassNotFound
如果沒配置第3步,會報java.lang.IllegalStateException: Workspace is closed.
最後更新:2017-04-03 14:54:27