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 :

[pastacode lang=”markup” manual=”%3Cproject%20xmlns%3D%22http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%0A%20%20%20%20%20%20%20%20%20xsi%3AschemaLocation%3D%22http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0%20http%3A%2F%2Fmaven.apache.org%2Fxsd%2Fmaven-4.0.0.xsd%22%3E%0A%20%20%20%20…..%0A%20%20%20%20%3Cdependencies%3E%0A%20%20%20%20%20%20%20%20……%0A%20%20%20%20%20%20%20%20%3C!–MySQL%20dependency–%3E%0A%20%20%20%20%20%20%20%20%3Cdependency%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CgroupId%3Emysql%3C%2FgroupId%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CartifactId%3Emysql-connector-java%3C%2FartifactId%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cversion%3E5.1.43%3C%2Fversion%3E%0A%20%20%20%20%20%20%20%20%3C%2Fdependency%3E%0A%20%20%20%20%3C%2Fdependencies%3E%0A%3C%2Fproject%3E” message=”” highlight=”” provider=”manual”/]

3 – Run customize target

[pastacode lang=”bash” manual=”%2Fhybris%2Fbin%2Fplatform%24%20ant%20customize” message=”” highlight=”” provider=”manual”/]

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

[pastacode lang=”bash” manual=”%2Fconfig%2Fcustomize%24%20vim%20.%2Fplatform%2Fcustomize_setantenv.sh” message=”” highlight=”” provider=”manual”/]

2 – Add following content on this file :

[pastacode lang=”bash” manual=”%23!%2Fbin%2Fsh%20%0A%0A.%20.%2Fsetantenv.sh%20%0A%0Aexport%20ANT_OPTS%3D%22-Xmx4g%20-Dfile.encoding%3DUTF-8%20-Djdk.util.jar.enableMultiRelease%3Dforce%22″ message=”” highlight=”” provider=”manual”/]

3 – Run customize target

[pastacode lang=”bash” manual=”%2Fhybris%2Fbin%2Fplatform%24%20ant%20customize” message=”” highlight=”” provider=”manual”/]

4 – Use customize_setantenv.sh instead of setantenv.sh

[pastacode lang=”bash” manual=”%2Fhybris%2Fbin%2Fplatform%24%20.%20.%2Fcustomize_setantenv.sh” message=”” highlight=”” provider=”manual”/]

0 0 votes
Article Rating
Subscribe
Notify of
guest

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

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x