简体   繁体   English

如何在没有 Eclipse 的情况下创建 IProject

[英]How to create IProject without Eclipse

I'm trying to mavenize a third part Eclipse's plugin, but I need to create an instance of IProject to pass at JavaCore.create(instance) to obtain an instance of IJavaProject.我正在尝试对第三方 Eclipse 插件进行 mavenize,但我需要创建一个 IProject 实例以在JavaCore.create(instance)处传递以获取 IJavaProject 实例。

This application will not have workspace and will be better that depends from eclipse's libraries as less as I can.该应用程序将没有工作区,并且尽可能少地依赖 eclipse 的库会更好。

So I can't use:所以我不能使用:

ResourcesPlugin.getWorkspace().getRoot().getProject(...);

When I try to start my program I have this error report:当我尝试启动我的程序时,我收到此错误报告:

Exception in thread "main" java.lang.IllegalStateException: Workspace is closed.
    at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:367)
    at gr.uom.java.jdeodorant.helpers.JavaProjectHelper.createJavaProject(JavaProjectHelper.java:55)
    at gr.uom.java.jdeodorant.refactoring.actions.Index.initializeJavaProject(Index.java:28)
    at gr.uom.java.jdeodorant.refactoring.actions.Index.main(Index.java:53)

So is there any way to create this instance outside Eclipse, just passing the path of the project that I need?那么有什么方法可以在 Eclipse 之外创建这个实例,只需传递我需要的项目路径? Some ideas?一些想法?

The short answer: no.简短的回答:不。

The workspace requires the OSGi framework to start, and set the osgi.instance.area property.工作区需要启动 OSGi 框架,并设置osgi.instance.area属性。 It also needs some of the other org.eclipse.core.runtime services to be started.它还需要启动其他一些org.eclipse.core.runtime服务。

JavaCore.create(*) is in JDT... parts of org.eclipse.jdt.core might run without having the UI workbench up, but that really depend on which parts. JavaCore.create(*) 在 JDT 中... org.eclipse.jdt.core的一部分可能在没有 UI 工作台的情况下运行,但这实际上取决于哪些部分。

It might be possible to run a HEADLESS RCP application that includes the org.eclipse.core.runtime and org.eclipse.core.resources (workspace) without including any of the UI components, but you won't be able to use the workspace without starting up OSGi and the core runtime.可以运行包含org.eclipse.core.runtimeorg.eclipse.core.resources (工作区)的 HEADLESS RCP 应用程序,但不包含任何 UI 组件,但您将无法使用工作区无需启动 OSGi 和核心运行时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM