简体   繁体   English

具有Eclipse中超级项目相关性的Java子项目

[英]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: 注意事项:

  • I cannot use Maven, the build process is included in a synchronization workflow with the robot system through the modified Eclipse. 我无法使用Maven,通过修改后的Eclipse,构建过程包含在与机器人系统的同步工作流程中。
  • It can be considered that all code in the subproject is available in both versions of the robotics library. 可以认为,子项目中的所有代码在两个版本的机械手库中均可用。
  • Classes in that sub project must be inheriting from library classes, so they have to be imported directly. 该子项目中的类必须继承自库类,因此必须直接将其导入。
  • The contents of the robotics library cannot be changed. 机器人库的内容无法更改。

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.

相关问题 使用Eclipse将Java项目作为依赖项添加到Android项目 - Adding a Java project as a Dependency to an Android project with Eclipse 如何让我的子项目从多模块Maven项目中的超级项目继承依赖项版本? - How can I get my sub projects to inherit dependency versions from the super project in a multi module Maven project? 如何在Java Eclipse中从当前项目的依赖项jar中启用日志记录? - How to enable logging from a dependency jar in the current project in java eclipse? 在Java项目视图中折叠NetBeans或Eclipse中的子包 - Collapsing sub-packages from NetBeans or Eclipse in java project view Scala项目是eclipse中Java项目的“子项目” - Scala project as “sub-project” of Java project in eclipse Eclipse项目和Maven依赖 - Eclipse project and maven dependency Gradle 复合构建 - 您是否可以依赖包含的多项目构建中的 java 子项目? - Gradle composite builds - can you have a dependency to a java sub-project from an included multi-project build? Java项目对另一个项目的依赖 - Java project dependency on another project 如何在.eclipse中包含.war文件作为java web项目依赖? - How to include .war file as a java web project dependency in eclipse? 如何在Eclipse中将另一个Java项目打包为osgi依赖项 - How to package another java project as an osgi dependency in eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM