[英]Java sub project with dependency from super project in Eclipse
I am developing a Java robotics application in a proprietary Eclipse environment. 我正在专有的Eclipse环境中开发Java机器人应用程序。
Some of my packages shall be used in other applications, so I moved them into a separate (sub) project. 我的某些软件包将在其他应用程序中使用,因此我将它们移到了一个单独的(子)项目中。 The code in this sub project relies on the robotics libraries. 该子项目中的代码依赖于机器人库。 However, the separate applications are running on different versions of this library. 但是,单独的应用程序正在此库的不同版本上运行。 I now want some sweet way of providing this shared sub project to my colleagues without having the robotics library as a hard dependency to leave it to them using the respective version. 我现在想要一种甜蜜的方式来向我的同事提供此共享子项目,而又无需将机器人库作为硬性依赖关系来使用各自的版本将其留给他们。
In an application project this shared sub project is included as a dependency as well as the library. 在应用程序项目中,此共享子项目也作为依赖项以及库包含在内。 So in C++ I could just use typenames since the linking would be provided later - but how to do this in Java? 所以在C ++中,我只能使用类型名,因为稍后会提供链接- 但是如何在Java中做到这一点?
Little drawing to make the setup clearer: Overview of project setup 小图使设置更清晰: 项目设置概述
Things to note: 注意事项:
There is no sweet way to do this like you would like. 没有像您想要的那样甜美的方法来做到这一点。 The only way to accomplish this in Eclipse without using Maven would be to have the unique dependency versions included in the Eclipse project's classpath. 不使用Maven在Eclipse中完成此操作的唯一方法是在Eclipse项目的类路径中包含唯一的依赖版本。 Java doesn't care about what version of the libraries are included on the classpath, as long as all of the required classes, methods, etc. exist in the library class files. 只要库类文件中存在所有必需的类,方法等,Java都不关心类路径中包括哪些版本的库。 This is just a bad practice because if you are developing with one version of a library, it would be hard to always guarantee that the code you are writing is also compatible with the library that your colleague is using. 这只是一种不好的做法,因为如果您使用一个版本的库进行开发,将很难始终保证所编写的代码也与您的同事使用的库兼容。
The best way, without Maven, would be to include all the required libraries in a lib directory of your project so that all developers are using the same ones. 没有Maven的最佳方法是将所有必需的库包含在项目的lib目录中,以便所有开发人员都使用相同的库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.