How to use Maven dependencies inside the Hybris extension

July 11, 2017
Hot topics 🔥
Tech Insights
Jack Myasushkin
How to use Maven dependencies inside the Hybris extension

So we’ve been stuck on this for some time due to the lack of official documentation regarding this topic. But with a mix of research, trial and error and sheer luck, we’ve managed to come up with a solution. But before the solution, the problem: you don’t want to reinvent the wheel each time, and there are a lot of packages out there created by other developers. But one of the main repositories for this issue is Maven and you can use it inside your custom Hybris extension. Let us show you how to make it work:


Let’s suppose that we have a custom training extension. Each extension has:

  • External-dependencies.xml file, which contains definitions about what packages you want to use, and;
  • A lib folder, in which packages will be stored

Please make sure the lib folder is added as a module dependency. In general, it is should be done automatically, but just to make 100% sure I propose to check it. For that go to File -> Project Structure and in the list of modules, select training.

In the picture above we can see that training/lib is added as a module dependencies path, so all is configured properly. If you do not have this entry then just add it manually.


One of the main steps is to configure extensionsinfo.xml. This file contains some general extensions configuration, such as dependencies on some other extensions, web module config and others. But, right now we only need one small change which should be done to tell the system to download maven packages into the lib folder.

As you can see, a property (called usemaven) has a false value. And we should to change it to a true value to make maven dependencies available.

Ant commands

Hybris actively uses the Ant build tool to perform some system tasks. One of these is to update maven dependencies for an extension. It looks like this:

ant updateMavenDependencies

Very obvious, though.

Okay, let’s try!

For example, we will want to use HTTP client inside our extension. A good candidate for that is a library by Apache. Lets add an entry into external-dependencies.xml file.

And now, go to the terminal and run ant updateMavenDependencies. If you see ‘BUILD SUCCESSFUL’ then you can observe the appropriate package file inside the lib folder.

And that’s it! Now you can use the functionality which this package provides inside your own code!

Happy hacking!

Jack Myasushkin

Jack is WeAreBrain's CTO and Co-founder. Originally from Ukraine, he has skipped between Ukraine, the United States and the Netherlands throughout his career.

Working Machines

An executive’s guide to AI and Intelligent Automation. Working Machines takes a look at how the renewed vigour for the development of Artificial Intelligence and Intelligent Automation technology has begun to change how businesses operate.