[英]java eclipse build path options question
I have a question on Eclipse (I am using Helios). 我有一个关于Eclipse的问题(我正在使用Helios)。
When a project depends on various libraries, we add them to the classpath via the Build Path Dialog. 当项目依赖于各种库时,我们通过Build Path Dialog将它们添加到类路径中。
In the same dialog though, there is a tab for Projects (Required Projects on the build path). 但是,在同一个对话框中,有一个Projects选项卡(构建路径上的Required Projects)。
It is not clear to me, when someone would add such a reference from one project to another. 当有人将这样的参考从一个项目添加到另一个项目时,我不清楚。
I mean, if projectA needs functionality from projectB, then we can make a jar out of projectB and use it in projectA. 我的意思是,如果projectA需要来自projectB的功能,那么我们可以从projectB中创建一个jar并在projectA中使用它。
But when, would we add then, a reference from projectA to projectB, in order to need projectB in the build path of projectA? 但是,当我们添加从projectA到projectB的引用时,为了在projectA的构建路径中需要projectB?
Could someone please give an example? 有人可以举个例子吗?
Thank you! 谢谢!
Well, there are two reasons for depending on a project. 那么,取决于项目有两个原因。
Update: I thought of a third one, possibly even better than the first two. 更新:我想到了第三个,甚至比前两个更好。 There is an "Order and Export" tab in the same screen, where you can select which elements of a project's classpath are exported.
在同一屏幕中有一个“Order and Export”选项卡,您可以在其中选择项目类路径的哪些元素被导出。 And what "exported" means here is exactly that if project B is configured to have project A as a dependency, then it will automatically add all the exported libraries from project A to its own classpath.
“导出”的含义正是如果项目B配置为将项目A作为依赖项,那么它将自动将项目A中的所有导出库添加到其自己的类路径中。 So if project A has a lot of thrid party libraries, you don't have to manually add them to project B's classpath.
因此,如果项目A有很多第三方库,则不必手动将它们添加到项目B的类路径中。
“必需项目”允许您在项目之间声明依赖关系,而无需在每次对所依赖的项目进行更改时构建jar。
One (for me nice, for others; perhaps, blasphemous) use of the "Project Dependancy" is when you have a seperate project for unit tests. 一个(对我来说很好,对于其他人;也许是亵渎神明的)使用“项目依赖性”是指你有一个单独的单元测试项目。 Make the unit test project depend on the to-be-tested project.
使单元测试项目依赖于待测项目。 Of course, this is only nice if you are not a maven or hudson or blah, blah, blah user (like me).
当然,如果你不是一个maven或者哈德森或者是等等,等等用户(就像我一样),那就太好了。 Not that blah, blah, blah are bad things.
不是说,等等,等等,是坏事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.