I have a question on Eclipse (I am using Helios).
When a project depends on various libraries, we add them to the classpath via the Build Path Dialog. In the same dialog though, there is a t开发者_如何学Cab for Projects (Required Projects on the build path). 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. But when, would we add then, a reference from projectA to projectB, in order to need projectB in the build path of projectA? Could someone please give an example? Thank you!Well, there are two reasons for depending on a project.
- You can "click through" to the source code of the other project when its code is invoked.
- If you're building and running the application in Eclipse for dev purposes, changes in the code will instantly be picked up.
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. 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. So if project A has a lot of thrid party libraries, you don't have to manually add them to project B's classpath.
"Required Projects" allow you to state dependencies between projects without the need to build a jar each time you make a change to the project you depend upon.
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). Not that blah, blah, blah are bad things.
精彩评论