Use Ant Customize command in Hybris
1. Overview
In Hybris, there are two types of files and directories :
- Custom files : The source code that we write, change and commit (eg. custom extensions).
- Read only files : The binary files that we can’t/shouldn’t change (eg. platform).
However, you may need to replace some read only binary files, eg. customize HMc css style.
To do so, you have to :
- Copy the original file that you want to customize inside the ${HYBRIS_CONFIG_DIR}/customize directory.
- Update and customize the file.
- Run ant customize.
In this article, I will show you how to use ant customize command.
2. Ant customize in action
For example, to customize the CSS style of the HMc, you need to replace the hmc.css file located in the ${HYBRIS_BIN_DIR}/ext-platform-optional/hmc/web/webroot/css directory.
2.1. Copy original file
Copy the hmc.css file inside inside the ${HYBRIS_CONFIG_DIR}/customize.
You have to keep the same folder structure, which mean ${HYBRIS_CONFIG_DIR}/customize/ext-platform-optional/hmc/web/webroot/css/hmc.css.
2.2. Update/Customize file
For this example, I will change the HMc header color.
/*** ... ***/
.page-header {
height: 71px;
background-color: red;
color: #ffffff;
vertical-align:top;
text-align:left;
white-space:nowrap;
color: #ffffff;
font-size: 10px;
}
/*** ... ***/
Update only the block you want to customize and keep the rest of the file.
2.3. Run ant customize
The ant customize command, will replace the customized files with original ones.
Start the Hybris server (run ant all if it’s needed) and see your changes.
Software Craftsmanship, Stackextend author and Full Stack developer with 6+ years of experience in Java/Kotlin, Java EE, Angular and Hybris…
I’m Passionate about Microservice architectures, Hexagonal architecture, Event Driven architecture, Event Sourcing and Domain Driven design (DDD)…
Huge fan of Clean Code school, SOLID, GRASP principles, Design Patterns, TDD and BDD.
Hi
But if i want to change some classes of ext-commerce extension and i perform same steps then it will create a problem during git versioning because i cannot push my files present in config folder
Hello, I do not totally agree with you, because in most cases the config folder belongs to the project sources and should be committed to git too (it is not different from custom extensions).
Yeah i agree as i tried it on my local machine.Thank you
Hey Mouad!
I am really sorry for the off-topic question, but I haven’t managed to find the answer on the Internet.
The thing is that in the docs it is stated that setting autocreate to false on the item type level should cause build failure in case the item type is a new one.
Let’s say I create my new own type:
The build is successful, which is strange
Thank you in advance!
Hey Nick,
Setting
autocreate
to false should cause build failure in case the item is new and has at least one attribute.Such a rapid response!
Thank you a lot, Mouad!
Guess they should have mentioned that minor detail in the specs though
Hi Mouad,
I have a question on above post, let suppose i need to customise some UI for browser area of csmcockpit by adding some new buttons and functionality let say big customisation then it will involve lots of file changes from different dependant extension and to copy them in config is it recommendable.
Main thing is , is it recommendable to do big customisations?
Thanks in advance
in my opinion, it’s not recommended to do something like this.
Even if it’s possible to do this will be a hard work on such deprecated extension.
how to override a file which is in Addon ???
the addon is installed into your web extension, so you can customize its code on your web extension
after been installed, no need of ant customize for this type of request.
Is there any way to restore the original state of the file after having called the “customize” target?
ant clean
Hm, maybe I missed smth, cause it looked like it did not restore after ‘clean’
will double check – thank you a lot!
I have the same problem. ‘ant clean’ doesn’t restore original state. Did you resolve it?
How to revert the changes back to original? I tried removing the my changes in customize folder and running ant clean all, ant customize, but then also, it is not working.
No I am not able to revert back to original like OTB
I need to replace log4j core jar form platform but unable to do using ant customize.Can you suggest way
You can use ant callbacks like how I did here : https://www.stackextend.com/hybris/upgrade-log4j-version-on-sap-hybris-commerce-tofix-vulnerability/
Hii,
Need to perform ant customize for Hybris v 2005. Is it possible?
I tried doing the same steps but it creates a duplicate folder instead of overriding.