How to add dependencies in hybris using external-dependencies.xml file?
Asked Answered
H

3

7

I'm newbie in hybris. I want to add maven dependency in hybris using external-dependencies.xml. But I can't see any of those jar(s) popped-in. Is it possible to get jar using external-dependencies.xml, if yes, please provide your response.

Homolographic answered 3/1, 2017 at 13:9 Comment(2)
Did you add usemaven="true" in your extensioninfo.xml (extension tag)?Distributary
@Distributary It is working as expected with "usemaven" attribute in extension tag. Thank you vert much.Homolographic
S
23

The platform build is coupled with ant but you can use maven dependency (by default is disabled because all necessary libraries are shipped with the hybris).

In order to activate dependency management you have to follow these steps:

1) Make sure you have maven installed

2) Open the extensioninfo.xml from your extension 2.1) Include usemaven="true", for instance

enter image description here

3) Manage your dependencies inside "external-dependencies.xml" file (Inside this file is a regular maven pom.xml)

4) build your project (ant all). Hybris fetch required libraries into \lib and \web\webroot\WEB-INF\lib (Bear in mind that there are two "external-dependencies.xml", one for the core module and other for the web module)

Besides if you look the ant targets you will see there is one call "updateMavenDependencies". This task delete all jars in the lib folder and replaces them with the defined maven dependencies. In case you dont want maven to manage a few libraries you can handle this, creating a file in the root of your extension call "unmanaged-dependencies.txt".On this file you will include all libraries maven is not going to manage (therefore the ant target is not going to delete the libraries include on this file)

Saddler answered 1/2, 2017 at 22:37 Comment(2)
Even though this is a pretty old answer at time of writing this comment you may also pay attention to the '.lastupdate' file generated during build. if this file exists the build will not download any dependency at all. So if you want to have your libs updated, e.g. to download new version, you need to delete the file if it exists.Clarkia
Thanks @Fernando. I just make your answer shorten. - Allow maven build in extention by update usemaven="true" in extensioninfo.xml file - In external-dependencies.xml file. add the dependencies want to import. - NOTE: all libs in the lib folder will be remove when build. - To prevent remove existed libs. add all libs name into the unmanaged-dependencies.txt file.Donalt
D
5

My official answer: add usemaven="true" in your extensioninfo.xml (extension tag)

Distributary answered 5/1, 2017 at 15:47 Comment(0)
Z
-2

I'm newbie too to Hybris but what I know is that whenever you need a dependency in a Hybris extension you need to add the name of the dependency to hybris/config/localextensions.xml and in extensioninfo.xml in the extension you want to add the dependency.

As for the Maven dependency, I'm not sure how to do that because I mostly use the out-of-the-box build system which is based on Ant.

Zootechnics answered 4/1, 2017 at 14:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.