preloder

How to utilize build tools in SAP Hybris commerce

SAP
Build tools, hybris

How to utilize build tools in SAP Hybris commerce

Published on June 13, 2018

I am writing this blog post to give a bird’s eye view of different build tools used in SAP Hybris commerce and its responsibilities and how does it fit in the overall build process without getting into too much detail.

SAP Hybris Commerce uses a number of build tools for automating tasks like code generation, copying, parsing files and managing external library dependencies.

The below tools are used

  • Apache Ant
  • Apache Maven
  • Gradle

Apache Ant

Apache Ant is a tool for automating the build processes(compiling, executing tests, packaging) of Java applications. Though it is quite old compared to other build tools it is responsible for most of the tasks in the Build process of SAP Hybris Commerce.
The build steps are defined in an XML file(build.xml) which includes a combination of targets and tasks which forms the backbone of Build framework in Hybris Commerce. build.xml is present in {Hybris-Home}/bin/platform/ directory and it is bootstrapped to all the extensions in localextensions.xml file during the initial build which will have only the required ant targets which are specific for an extension.
An Ant target is a container of tasks which will be executed to perform an operation in the build process. Below is the Ant target snippet for extgen which is used for creating extensions based on pre-defined extension templates in Hybris. This is present in {Hybris-Home}/bin/platform/build.xml file and can be invoked by the command ant extgen.
<target name="extgen" description="Runs extgen">
<callback extname="" target="before_extgen"/>
<extgen_generate/>
<callback extname="" target="after_extgen"/>
</target>
Hybris Commerce comes up with quite a few Ant targets to perform different operations in its build process. The list of available ant targets can be known by executing the ant -p command from the {Hybris-Home}/bin/platform directory
A Custom build logic can be introduced in the build process by making changes on the buildcallbacks.xml files present inside the extension directories. A buildcallbacks.xml file has both macrodefs and global ant targets which will affect the build process. By defining a macrodef a logic can be implemented to perform activities such as overwrite, delete, or copy files for an extension. Ant targets which are defined in the buildcallbacks.xml file of an extension is globally available unlike the ones available in extension specific build.xml file.

 

Apache Maven

Apache Maven is a build automation tool which is responsible for building the software and managing its dependencies. The main use of Maven in Hybris Commerce is to manage its external library dependencies.

All the required external library dependencies for an extension are defined in external-dependencies.xml file inside the extension directory. Based on the purpose there are two possibilities which are defined in the below table:

Dependencies defined in Purpose Path where the libraries are added to
<extension folder>/external-dependendencies.xml Libraries for Global classpath <extension folder>/lib
<extension folder>/web/webroot/WEB-INF/external-dependendencies.xml Libraries for Web module of the extension <extension folder>/web/webroot/WEB-INF/lib

Apart from this, Maven is also used for the creation Hybris Datahub extensions.

Gradle

Gradle is a modern build management tool which supports a range of programming languages including Java.

This tool is mainly used for installing recipes in Hybris Commerce. Recipes is a new concept introduced with SAP Hybris Commerce 6 to automate the installation of different flavors (B2C, B2B) and different accelerators(Marketplace, China) and different functionalities(CPQ, OMS) during the setup.

Basically, upon doing a recipe installation, it will introduce a list of predefined extensions in localextensions.xml and introduce a list of properties in local.properties file. Optionally tasks related to starting the server(this is already available in the Out of the Box recipes) and creating build images for deployment can be specified in our custom gradle scripts.

Higher level representation of the responsibilities of different build tools in SAP Hybris Commerce


Learn more about how we add value!

Start a Project

X

  • WORK WITH US

    Before we start, please fill this form to provide us some basic information.

  • This field is for validation purposes and should be left unchanged.
X

Oops! We could not locate your form.

  • Referrals for FAIR employees

    Please confirm your company email to submit your referral


X