Chapter 5. Add HDP Maven Repository to Existing Project

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Maven projects are defined by their Project Object Model or pom. This file is located in the base directory of a maven project and is called pom.xml.

Use one of the following options to add HDP Maven repository as a default repository in your existing project:

  • Option I: Add HDP Maven repository to existing Maven project

    A repository in Maven is used to hold build artifacts and dependencies of varying types. There are strictly only two types of repositories: local and remote.

    The local repository refers to a copy on your own installation that is a cache of the remote downloads, and also contains the temporary build artifacts that you have not yet released. Remote repositories refer to any other type of repository, accessed by a variety of protocols such as file:// and http:// These repositories might be a truly remote repository set up by a third party to provide their artifacts for downloading (for example, repo.maven.apache.org hosts Maven's central repository). Other "remote" repositories may be internal repositories set up on a file or HTTP server within your company, used to share private artifacts between development teams and for releases.

    To add HDP Maven repository, add the following lines to your Maven project's pom.xml file:

    <repositories>
        <repository>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>false</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
          <id>HDPReleases</id>
          <name>HDP Releases</name>
          <url>//repo.hortonworks.com/content/repositories/releases/</url>
          <layout>default</layout>
        </repository>
      </repositories> 
  • Option II: Add HDP Maven repository to existing Ant/Ivy project

    Apache Ivy repositories are configured inside the <resolvers> element of an ivysettings.xml file. Usually, the resolvers (where to get those required artifacts) are provided through a separate file,ivysettings.xml file.

    The ivysettings.xml file holds a chain of Ivy resolvers used for both resolution and publishing (deployment). Resolvers exist for both regular artifacts and Ivy module files. Apache Ivy uses chain to define the preference order for the repositories. Inside the <chain> element, you will find a <url> element. The <url> element is a remote site that contains bundle dependencies.

    To add HDP Maven repository to existing Ant/Ivy project, add a new resolver to the existing Ivy chain so that HDP versioned artifacts can be resolved.

  • Option III: Setup Maven proxy

    It is often the case that users wish to set up a Maven proxy repository inside their corporate firewall and have developer instances resolve artifacts through such a proxy. Proxy repositories provide a single point of remote download for an organization. In addition to control and security concerns, Proxy repositories are primarily important for increased speed across a team. These scenarios can be realized by using internal Maven repositories and a Maven proxy.

    To setup maven proxy pointing to HDP Maven or Nexus repository, use the following URL (//repo.hortonworks.com/content/repositories/releases/) for caching the HDP artifacts to your local or internal Maven, Nexus, or Archiva repositories respectively.