简体   繁体   English

将纯Java项目作为类路径添加到eclipse插件

[英]Adding plain Java project as a classpath to an eclipse plugin

I have a plain Java project (not a plugin project) which I want to add to a classpath of a eclipse plugin which I am developing. 我有一个普通的Java项目(不是插件项目),我想添加到我正在开发的eclipse插件的类路径中。 But in web projects I can add that project as a build path and it works fine. 但是在Web项目中,我可以将该项目添加为构建路径,并且效果很好。 But I tried same thing in eclipse plugin, I am able to compile successfully, but at run time I am getting java.lang.ClassNotFoundException . 但是我在eclipse插件中尝试了同样的事情,我能够成功编译,但是在运行时我得到了java.lang.ClassNotFoundException

I know OSGi quite well and I know how to add OSGi into an classpath (using export-packages) but what I want is to add Standard, non-osgi project into an classpath, so that I wont' get runtime errors. 我非常了解OSGi,也知道如何将OSGi添加到类路径(使用导出包),但是我想要的是将Standard,non-osgi项目添加到类路径中,这样我就不会出现运行时错误。 Is there anyway I can achieve this? 无论如何,我能做到这一点吗?

I can export project as a jar file or make it as a plugin project and it would work fine. 我可以将项目导出为jar文件,也可以将其导出为插件项目,这样就可以正常工作。 But that's not my option currently because, still that API is in pre-alpha stage, and there would be lot of changes going on. 但这目前不是我的选择,因为该API仍处于pre-alpha阶段,并且会有很多更改。 So I am trying to avoid pain of exporting it as jar file everytime. 因此,我试图避免每次都将其导出为jar文件的麻烦。 Is there any option for me other than this? 除此之外,还有其他选择吗?

I have a similar situation: I want non-OSGi Maven dependencies integrated into the classpath of my plugin. 我有一个类似的情况:我想将非OSGi Maven依赖项集成到我插件的类路径中。 I succeeded with a roundabout solution, which I think is the best I could get. 我成功实现了环岛解决方案,我认为这是我能得到的最好的解决方案。

I have a build step outside of Eclipse where I copy the class files of the dependency into the plugin's lib folder. 我在Eclipse之外进行了构建,将依赖项的类文件复制到了插件的lib文件夹中。 The lib folder is specified in MANIFEST.MF as an entry in Bundle-ClassPath and (here comes the hack) as a source folder in build.properties . lib文件夹在MANIFEST.MF指定为Bundle-ClassPath的条目,而在build.properties文件夹(此处为hack)。 That was the only way to make the plugin work both when launched from within Eclipse and when exported. 这是使插件在Eclipse中启动和导出时均能正常工作的唯一方法。

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

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