Files customization in SAP Hybris (Add dependency to platform + Customize setantenv.sh)

Hybris Logo

SAP Hybris solution is thinking always about you, and offer the ability for his clients to customize their OOTB resources.

So which problems can be solved by using this option ?

Basically the OOTB customization become a necessary task when the OOTB should be adjusted to serve the technical needs like :

  • Override the platform external dependencies file to add a new library (Exemple 1)
  • Add a custom setantenv.sh script (Exemple 2)

1. Idea

Their is a customize folder in the config folder generated when we run ant all at the first time, and this one is used specially to replace native SAP Hybris resources by adding custom resources in the customize folder with the same path, which means if you want to customize a file like HYBRIS_DIR/bin/platform/build.xml you need to add your custom build.xml in the following folder HYBRIS_DIR/config/customize/platform/ and then run ant customize before ant all.

2. Implementation

2.1. Example 1 :

To add new database external dependency properly in the platform extension, we need to replace platform HYBRIS_DIR/bin/platform/lib/dbdriver/external-dependencies.xml by a new one where the database dependency should be added to the dependencies tag.

Steps :

1 – Copy HYBRIS_DIR/bin/platform/lib/dbdriver/external-dependencies.xml in HYBRIS_DIR/config/customize/platform/lib/dbdriver/external-dependencies.xml

2 – Add the new dependency to HYBRIS_DIR/config/customize/platform/lib/dbdriver/external-dependencies.xml file

Should look like that :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    .....
    <dependencies>
        ......
        <!--MySQL dependency-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.43</version>
        </dependency>
    </dependencies>
</project>

3 – Run customize target

/hybris/bin/platform$ ant customize

2.2. Example 2 :

It’s helpful trick special for developer who has many ENV variables need to be declared with setantenv.sh, it could be also a why to add more memory to your ANT_OPTS variable, so to do you need to follow these steps :

1 – Create new file called customize_setantenv.sh

/config/customize$ vim ./platform/customize_setantenv.sh

2 – Add following content on this file :

#!/bin/sh 

. ./setantenv.sh 

export ANT_OPTS="-Xmx4g -Dfile.encoding=UTF-8 -Djdk.util.jar.enableMultiRelease=force"

3 – Run customize target

/hybris/bin/platform$ ant customize

4 – Use customize_setantenv.sh instead of setantenv.sh

/hybris/bin/platform$ . ./customize_setantenv.sh

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of