如果数据模型不需要更新,如何减少 Hybris 构建时间?

How to decrease Hybris build time in case the data model does not need an update?

假设需要完成一项任务,并且不需要更改数据模型(即 items.xml 不需要修改 )。 例如,现有项目类型需要一个新的拦截器。在这种情况下,我只需要一个新的 spring bean 和一个新的 Java class.

在我进行更改后,如果我 运行 一个 "ant build" 大约需要 1:30(一分半钟),有时甚至更多。

根据我的观察,Hybris 会尝试检查 localExtension.xml 中包含的每个扩展及其所需的扩展,这会花费很多时间。

如何执行更快的构建?它不应该花那么多时间,因为 我的拦截器案例中唯一需要的是编译新的拦截器 class,仅此而已。

我知道当数据模型发生变化时,需要删除 models.jar,需要生成新的源代码并在新的 models.jar 中编译,这需要时间。但在更简单的情况下,它应该工作得更快。

PS:我知道 JRebel,但这个问题解决了开发人员没有 JRebel 的情况。

platform/build.xml下面添加ant目标:

<target name="compileExtensions" description="Compiles only the provided extensions">
    <compile_only_specified_extensions/>
</target>

platform/resources/ant/compiling.xml中添加宏定义:

<macrodef name="compile_only_specified_extensions">
    <sequential>
        <foreachextprovidedincli>
            <do>
                <if>
                    <not>
                        <isset property="ext.@{extname}.warextension" />
                    </not>
                    <then>
                        <extension_compile extname="@{extname}" />
                    </then>
                    <else>
                        <external_extension_build extname="@{extname}"/>
                    </else>
                </if>
            </do>
        </foreachextprovidedincli>
    </sequential>
</macrodef>

在platform/resources/ant/util.xml

中定义foreachextprovidedincli
<macrodef name="foreachextprovidedincli">
    <element name="do" optional="false" />
    <attribute name="param" default="extname" />
    <sequential>
        <for list="${extensions.to.compile}" param="@{param}" delimiter=";">
            <sequential>
                <do />
            </sequential>
        </for>
    </sequential>
</macrodef>

现在我需要做的就是编译我的 类 运行 以下命令:

ant compileExtensions -Dextensions.to.compile="extensionName1;extensionName2;extensionName3"

使用上述命令,构建减少到 4 秒。