Build time can significantly influence your development speed on SAP Commerce Cloud. Optimizing the build process can greatly enhance your productivity as an SAP Commerce Cloud developer.
In this article, we will discuss how to diagnose build duration issues and provide valuable tips for reducing build time.
Build duration troubleshooting
Total build time
The total time of the build is displayed in the console at the end of the ant task execution.
Build time per extension
There are three main phases during a build:
- Preparation
- Dependency update
- Extension building
Building extensions is by far the most time-consuming phase. To identify extensions with lengthy build time, you should modify <HYBRIS_HOME>/bin/platform/resources/ant/compiling.xml and the ‘macrodef’ called extension_build such as demonstrated below:
<macrodef name= "extension_build" > <attribute name= "extname" /> <sequential> <prepare /> <stopwatch name= "@{extname}" /> ............... <echo message= "@{extname} Build finished on ${finish.time}." ></echo> <record name= "${HYBRIS_LOG_DIR}/extensions_build_time.log" action= "start" append= "false" /> <stopwatch name= "@{extname}" action= "total" /> <record name= "${HYBRIS_LOG_DIR}/extensions_build_time.log" action= "stop" /> </sequential> </macrodef> |
You will get a log file called extensions_build_time.log with such logs:
Now, with your favourite text editor, open extensions_build_time.log:
- Replace ‘
[stopwatch] [
‘ by ” - Replace ‘
sec]
‘ by ” - Replace ‘: ‘ by ‘,’
- Search for ‘:’ and replace minutes by the value in seconds (ex:
5:12.413
=>312.413
)
Now rename extensions_build_time.log to extensions_build_time.csv and open the file into Excel.
In Excel, sort from the Largest to Smallest and calculate the total. Here is an example from my local installation with the full list of 310 extensions extensionmonitor.csv.
Tips
Use ant all in place of ant clean all
ant clean all first removes all compiled / generated files and then build the application. On my local machine, the operation takes 5 min.
ant all builds the application only for the extensions that have changed. On my local installation, the operation takes 30 seconds.
As you can see, using ant all command instead of ant clean all can save you a significant amount of time. However, it’s important to periodically use ‘ant clean all’ to ensure that your build does not include any orphaned files, or to resolve any unusual errors that may arise from a “dirty” build containing outdated files.
Minimize the number of extensions
As each extension contribute to build time, removing extensions that you do not use in your project is critical for the time of the build and restart.
Pro tip: I like to have two installations on my machine that points to the same custom folder: one core installation with the minimal set of extensions require for platform development (back-office, item type, DOA and services layers) and one with the full set of extensions (with frontend extensions such as yacceleratorstorefront). This way for most of my development I can use the core installation and when I need to do frontend development, I can switch to the full set of extensions.
Build only when necessary
A typical developer mistake is to launch a new build for each modification.
Understand when a build is required can save you a lot of time.
Item | /<my_ext>/resources/<my_ext>-items.xml | x | x | x | |||||
Spring configuration | /<my_ext>/resources/<my_ext>-spring.xml | x | |||||||
Java | /<my_ext>/src/ | x | x | ||||||
local.properties | /config/local.properties | x | |||||||
local.properties (Tomcat parameters) | /config/local.properties | x | x | ||||||
Backoffice configuration | /<my_ext>/backoffice/resources | x | x | ||||||
Localization file (website) | /<my_ext>/resources/localization/<my_ext>-locales_en.properties | x | |||||||
Localization file (cockpit) | /<my_ext>/resources/localization/<my_ext>-locales_en.properties | x | x | ||||||
CronJob Spring configuration | /<my_ext>/resources/<my_ext>-spring.xml | x |
Optimize smartedittools extension
‘ant clean all’ will execute ‘pnpm install’ and ‘rush build‘, those two actions take minutes to complete and need an active and stable internet connection.
Since 2105-6, there is an enhancement and the property smartedittools.only.build.once should be set to true in local.properties so you can skip rush build and pnpm install.
Reload Code Changes Instantly with JRebel
Enable Hot Deployment for Backoffice
You can improve the performance of developers of Backoffice extensions by activating the Backoffice Dev toolbar
backoffice.cockpitng.development.mode= true backoffice.cockpitng.hotDeployment.enabled= true |
You can deploy at runtime Backoffice development.
File type |
Tool / method of the hot deployment |
---|---|
*-backoffice-widgets.xml / *-backoffice-config.xml |
Dev Toolbar, F4 + reset everything |
definition.xml and labels of widgets, actions or editors |
Backoffice Redeploy Extensions mechanism |
Java classes |
JRebel, DCEVM, JVM Hot Swap mechanism, Backoffice Redeploy Extensions mechanism |
Localization labels (for now only in <bo_extension>/resources/bo_extension-backoffice-labels/ – reloading of labels in widgets, actions or editors is not supported yet) |
Dev Toolbar |
scss |
ant sasscompile, then just refresh browser with reloading of resoruces ( CTRL + F5 ) |
Spring XML files |
JRebel, Backoffice Redeploy Extensions mechanism |
zul files, Images |
Automatic (just F5) after appropriate properties are enabled |
More details here: SAP Commerce Help page.
Disable Microsoft Defender Antivirus or Windows Indexing Service
Any process on your machine that analyses modified files may impact significantly the build time. On Windows, if you see degradation of the build time, consider adding hybris folder to exclusion list.