简体   繁体   English

eclipse无法从所需项目中导出软件包

[英]eclipse cannot export packages from a required project

I have the following projects setup in Eclipse Indigo SR1: 我在Eclipse Indigo SR1中设置了以下项目:

  • Normal Java project (A) which includes package (P) 包含程序包(P)的普通Java项目(A)
  • Plug-in project (B) which has a copy of the JAR that is exported from A and it then exports package P 插件项目(B),具有从A导出的JAR副本,然后导出包P
  • Multiple other Plug-in projects (C...Z) which imports package P 导入软件包P的多个其他插件项目(C ... Z)

What I want to do is get rid of the manual export and copy of the JAR from project A into project B. I do not want to convert this project to a plug-in project because the same project is used in a legacy application that does not use OSGi. 我想要做的是摆脱手动将JAR从项目A导出和复制到项目B的过程。我不想将此项目转换为插件项目,因为在具有以下功能的旧版应用程序中使用了相同的项目:不使用OSGi。

This is particularly annoying since when I update the JAR eclipse does not pickup the modified class files and all my breakpoints in there go crazy (a separate issue). 这特别令人讨厌,因为当我更新JAR eclipse时不会拾取修改后的类文件,并且我在那里的所有断点都发疯了(单独的问题)。

I thought I would be able to edit the project properties for B so that A was a "Required project" (Proeprties -> Java Build Path -> Projects), and since that essentially includes the source (at least I guess that is what the entry in .classpath is doing ) I figured I could then export package P from project B. However when I do this, eclipse just complains that plug-in project B does not contain package P. 我以为我可以编辑B的项目属性,以便A是“必需的项目”(Proeprties-> Java Build Path-> Projects),并且由于它实质上包括源代码(至少我猜这就是源代码) .classpath中的条目正在执行)我想可以从项目B中导出程序包P。但是,当我这样做时,eclipse只是抱怨插件项目B中不包含程序包P。

I figured I could just link the source folders from A into B but that's not really what I want to do. 我想我可以将源文件夹从A链接到B,但这并不是我真正想做的。

If a referenced project A is on the classpath then surely the plug-in project A should be able to export those packages, or am I wrong in this assumption? 如果被引用的项目A在类路径上,那么插件项目A当然应该能够导出那些软件包,或者在这种假设下我错了吗?

What is the best way to achieve what I want? 实现我想要的最好的方法是什么?

Cheers, Jason. 干杯,杰森。

you should consider using maven as your build tool. 您应该考虑使用maven作为构建工具。 the tool was built to automate exactly things you've described. 该工具旨在完全自动化您所描述的内容。 Maven 马文

You should convert your java project into a plugin project (an OSGi bundle) in this case. 在这种情况下,您应该将Java项目转换为插件项目(OSGi捆绑软件)。 You can still use it both as a regular jar and as a plugin. 您仍然可以将其用作常规jar和插件。 When you convert it, make sure it creates the MANIFEST.MF. 转换时,请确保它创建了MANIFEST.MF。 Just don't create an activator as that would require a dependency on org.eclipse.osgi , and don't add any other require-bundle dependencies. 只是不要创建激活器,因为那样会需要对org.eclipse.osgi的依赖,并且不要添加任何其他require-bundle依赖。

An OSGi bundle is really just a jar (which is fine) with an OSGi MANIFEST.MF that provides information like what packages are exported, any dependencies, etc. OSGi捆绑包实际上只是一个带有OSGi MANIFEST.MF的jar(很好),它提供诸如导出哪些软件包,任何依赖项等信息。

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

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