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:
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.
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:
Very obvious, though.
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!
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.