如何删除对其他项目的显式依赖? Eclipse 启动配置中的库?
在 Eclipse 中,可以在项目中创建启动配置,指定另一个项目的运行时依赖项。我发现的一个问题是,如果您有多个项目工作区,每个项目可能都有自己的库,那么很容易将辅助项目中的显式依赖项添加到另一个项目的库中,因此可能会发生更改。
此问题的一个示例如下:
proj1 +-- src +-- lib +-- jar1-v1.0.jar +-- jar2-v1.0.jar proj2 +-- src +-- proj2-tests.launch
我没有从 proj2/src 中的代码到 proj1/lib 中的库的依赖关系。尽管如此,我确实有从 proj2/src 到 proj1/src 的依赖关系,尽管由于 proj1/src 中的代码对其库 jar1-v1.0.jar 和 jar2.v1.0.jar 存在内部依赖关系,所以我必须将 proj2-tests.launch 中的依赖项添加到 proj1/lib 中的库。这转化为 proj2-tests.launch 中的以下难看的行:
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="proj1" type="1"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/proj1/lib/jar1-v1.0.jar" path="3" type="2"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/proj1/lib/jar2-v1.0.jar" path="3" type="2"/> "/>
如果不需要不时地改进软件、升级库等,这不会是一个大问题。考虑升级的常见需求将库 jar1-v1.0.jar 和 jar2-v1.0.jar 升级到其版本 v1.1。假设您在一个工作区中有大约 10 个项目,每个项目有大约 5 个库和大约 4 个启动配置。您在对库进行简单升级时会产生维护开销,这通常意味着对不需要的文件进行更改。或者也许我做错了什么...
我想说的是 proj2 依赖于 proj1 及其库,并将其转换为 *.launch 文件中的内容。这可能吗?
In Eclipse it is possible to create launch configurations in a project, specifying the runtime dependencies from another project. A problem I found was that if you have a multiple project workspace, being possible that each project has its own libraries, it is easy to add explicit dependencies in a secondary project to libraries that are of another project and therefore subject to change.
An example of this problem follows:
proj1 +-- src +-- lib +-- jar1-v1.0.jar +-- jar2-v1.0.jar proj2 +-- src +-- proj2-tests.launch
I don't have a dependency from the code in proj2/src to the libraries in proj1/lib. Nevertheless, I do have a dependency from proj2/src to proj1/src, although since there is an internal dependency in the code in proj1/src to its libraries jar1-v1.0.jar and jar2.v1.0.jar, I have to add a dependency in proj2-tests.launch to the libraries in proj1/lib. This translates to the following ugly lines in proj2-tests.launch:
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="proj1" type="1"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/proj1/lib/jar1-v1.0.jar" path="3" type="2"/> "/> <listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/proj1/lib/jar2-v1.0.jar" path="3" type="2"/> "/>
This wouldn't be a big problem if there wasn't the need from time to time to evolve the software, upgrade the libraries and etc. Consider the common need to upgrade the libraries jar1-v1.0.jar and jar2-v1.0.jar to their versions v1.1. Consider that you have about 10 projects in one workspace, having about 5 libraries each and about 4 launch configurations. You get a maintenance overhead in doing a simple upgrade of a library, which normally must imply changes in files for which there wasn't the need for. Or maybe I'm doing something wrong...
What I would like to state is proj2 depends on proj1 and on its libraries and having this translated to simply that in the *.launch files. Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非我弄错了,如果将project1添加到project2的构建路径中,则project2的启动器将包含正确的类路径,即使project1的依赖项发生变化:
alt 文本 http://img24.imageshack.us/img24/9511/eclipsebuildpath.png
(project2 的属性,Java 构建路径,选项卡“项目” )
Unless I am mistaken, if you add project1 to the build path of project2, the launcher for project2 will include the right classpath, even if the dependencies of project1 change:
alt text http://img24.imageshack.us/img24/9511/eclipsebuildpath.png
(properties of project2, Java Build Path, tab "Projects")