缺省情况下,PDE/构建委托功能部件结构来编译插件。按照深度优先原则来访问功能部件,而按照(由 OSGi 解析器确定的)依赖关系来编译每个功能部件中的插件。
这意味着,所给定捆绑软件的所有依赖项必须包含在同一功能部件中,或者包含在按照深度优先原则遍历功能部件包含层次结构时较早出现的功能部件中。这可能会使得很难组织您的功能部件。
Eclipse 3.5 中新增了构建器属性 flattenDependencies。如果将此属性设置为 true,那么将导致 PDE/构建对所有插件进行排序,无论这些插件是否超出功能部件的边界都是如此。然后 PDE/构建将生成一个新的构建脚本 compile.<feature>.xml,此脚本按照对所有插件的依赖项进行排序之后所获得的顺序来列示这些插件。这使您能够将捆绑软件按照其功能划分到不同的功能部件中,而不必担心它们的内部依赖关系。
如果指定了 flattenDependencies,那么 PDE/构建能够并行编译捆绑软件。它通过将已排序的捆绑软件列表划分到各个组中来完成此任务,而每个组中包含的捆绑软件仅依赖于较早出现的组中的捆绑软件。
然后,每个组都被打包在一项 Ant <parallel> 任务中。下列属性将控制并行化行为:
| parallelCompilation | 设置为 true 以启用并行编译。(需要 flattenDependencies=true) |
| parallelThreadCount | 要使用的最大线程数。缺省值为 3。对应于 Ant 并行任务的 threadCount。 |
| parallelThreadsPerProcessor | 每个可用处理器要使用的最大线程数。对应于 Ant 并行任务的 threadsPerProcessor。 |
最终生成的编译脚本与以下内容类似:
<project name="Compile master" default="main">
<target name="main">
<parallel threadsPerProcessor='3'>
<ant antfile="build.xml" dir="plugins/org.eclipse.osgi" target="build.jars"/>
</parallel>
<parallel threadsPerProcessor='3'>
<ant antfile="build.xml" dir="plugins/org.eclipse.equinox.common" target="build.jars"/>
<ant antfile="build.xml" dir="plugins/org.eclipse.equinox.p2.jarprocessor" target="build.jars"/>
</parallel>
<parallel threadsPerProcessor='3'>
<ant antfile="build.xml" dir="plugins/org.eclipse.update.configurator" target="build.jars"/>
<ant antfile="build.xml" dir="plugins/org.eclipse.equinox.simpleconfigurator" target="build.jars"/>
<ant antfile="build.xml" dir="plugins/org.eclipse.equinox.frameworkadmin" target="build.jars"/>
<ant antfile="build.xml" dir="plugins/org.eclipse.core.jobs" target="build.jars"/>
<ant antfile="build.xml" dir="plugins/org.eclipse.core.databinding.observable" target="build.jars"/>
<ant antfile="build.xml" dir="plugins/org.eclipse.swt" target="build.jars"/>
...