Building hybris Through a Proxy

Corporate IT organizations are notorious for making enterprise systems nearly unusable through their strict security policies. One such restriction is to prevent both ingress and egress traffic to the public Internet. So, what do you do when your enterprise application needs Internet access? In most cases, firewall requests for such access is strictly prohibited or a lengthy bureaucratic  process that puts your project’s timeline at risk. Most corporate IT organizations recognize the need for limited Internet access and deploy internal proxies. 

Most modern applications provide the ability to configure a proxy. Well, what happens when it doesn’t work? Either you go through the bureaucratic red tape and then hit the bar every evening until your request goes through, or you consume massive amounts of coffee and trace the piece of code that isn’t honoring the proxy. I opted for the latter when our hybris build refused to honor our proxy settings.

Hybris employs Apache Ant for its build system; however, it also delegates to Maven, through the Maven Ant Task, in order to obtain the dependencies for its extensions. This of course, requires Internet access to one or more of the public Maven Central repositories. Maven already has support for going through a proxy. Simply configure your settings.xml with your proxy settings.

The proxy example below is taken from


As is it turns out, the hybris build does not honor this, resulting in the build hanging on the Maven Central HTTP request for the first dependency.

I would be remiss if I do not mention the following alternate methods of setting the proxy that did not work.

1. Defining JVM proxy settings:

export ANT_OPTS="-Dhttp.proxyHost=yourproxyhost -Dhttp.proxyPort=yourproxyport"

2. Patch the Ant build.xml for hybris and use the <setproxy> task.

<setproxy proxyhost="yourproxyhost" proxyport="yourproxyport" />

3. Define an OS-level proxy.

export http_proxy=http://yourproxyhost:yourproxyport

As it turns out, there is a very simple reason why our Maven proxy definition in settings.xml was not getting picked up, the artifact:mvn task in <hybris install dir/hybris/bin/platform/resources/ant/mavenTasks.xml. The hybris build file does not define an external Maven installation for use. In this case, the Maven core libraries packaged in the Maven Ant Tasks JAR file are used. As such, your global settings.xml file is never consulted.

If you read the Mvn Task documentation you’ll quickly note that this is spelled out. Simply, update the artifact:mvn task in <hybris install dir>/hybris/bin/platform/resources/ant/mavenTasks.xml and define the mavenHome="/path/to/your maven installation” attribute. There are multiple occurrences of the artifact:mvn task; you should update the one defined in the updateLibFolder macro definition.

<macrodef name="updateLibFolder">
    <artifact:mvn pom="@{dependencyFile}" fork="true" failonerror=“true" mavenHome="/path/to/your maven installation">
        <arg value="dependency:copy-dependencies" />
        <arg value="-DoutputDirectory=@{libfolder}" />
        <arg value="-DoverWriteReleases=true" />
        <arg value="-DoverWriteSnapshots=true" />
        <arg value="-DoverWriteIfNewer=true" />
        <arg value="-DexcludeTransitive=true" />

At this point, your build should now be able to fetch the needed Maven dependencies through your proxy.

I hope you enjoyed this write up. Stay tuned for more posts on hybris, specifically around advanced AEM and Solr integration.