0
votes

Lets say that a task needs to be done and there are no data model changes needed(i.e items.xml does not need to be touched). For example a new Interceptor is needed for an existing Item Type. In this case I just need a new spring bean and a new Java class.

After I do the changes, If I run an "ant build" it takes approximately 1:30(one minute and a half), sometimes even more than that.

From what I noticed Hybris tries to check every extension that is included in localExtension.xml with their required extensions as well, and that is taking a lot of time.

How can I perform a faster build ? It should not take that much time since the only thing that is needed in my Interceptor case is to compile the new Interceptor class, and that's it.

I understand that when data model is changed the models.jar needs to be deleted, the new sources need to be generated and compiled in a new models.jar and that requires time. But in the more simple scenario it should work a lot faster.

PS: I know about JRebel but this question addresses the cases in which the developer does not have JRebel.

1

1 Answers

1
votes

In platform/build.xml add below ant target:

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

In platform/resources/ant/compiling.xml add the macro definition:

<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>

Define foreachextprovidedincli in platform/resources/ant/util.xml

<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>

Now what I simply have to do to compile my classes is run the following command:

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

With above command the build was reduced to 4 seconds.