且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“订单和出口"“Java 构建路径"中的选项卡

更新时间:2023-11-16 17:06:22

此选项卡似乎具有双重职责(请参阅 本帮助页面底部 了解少量细节).

一方面,它用作相关项目构建中所用资源的解析顺序(顺序"部分).另一方面,它还用于定义此构建路径的哪些部分贡献给依赖项目(那些在项目"选项卡中列出此项目以查看此首选项面板的项目)构建路径(导出"部分).

后一个功能就是为什么复选框存在于左侧,如您所问(请注意,不能取消选中-"符号,因为无法取消选择此项目中定义的源文件,如帮助文件中所述).如果贡献项目不导出该资源,则期望来自贡献项目的某些资源的依赖项目将无法编译/运行.

此 SO 帖子 以供证实.

What's the use of "Order and Export" tab in "Java Build Path" dialog box? By the name 'order', I can guess that JRE System library is searched before Plug-in Dependencies, but why do we have 'Export' in Build Path ? And what's it for the button left side of the elements?

ADDED

It's the example that I borrowed from Eclipse distilled.

The orderes.webapp depends on orders, but it's likely to use the classes defined in ubl and catalog.

In such a case, orders can export catalog and ubl so that the packages that depends on it can use catalog and ubl.

And something more about "Order and Export".

  1. The check of the left side button modifies the .classpath file to add exported=true such as <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.7.jar"/>.
  2. The src is always checked, and you can't uncheck it.

References

This tab seems to pull double duty (see bottom of this help page for small amount of detail).

On one hand, it functions as the order of resolution for resources used in the building of the project in question (the "Order" part). On the other, it also serves to define what parts of this build path are contributed to dependent projects' (those listing this project in the "projects" tab for their view of this preference panel) build paths (the "Export" part).

This latter function is why the checkboxes exist on the left hand side, as you ask (note that the '-' signs cannot be unchecked, as source files defined in this project cannot be deselected, as stated in help file). A dependent project that expects some resource from the contributing project will not compile/run if the contributing project doesn't export that resource.

EDIT: see this SO post for corroboration.