How to configure P2 to cache artifacts in Artifactory (remote repository)

To configure P2 to cache artifacts in Artifactory, You will need to add a remote repository that will point to the URL where the artifacts that you would like to work with are stored.

Remote repository can be created in the UI under Admin tab ? Configuration ? Repositories.

For creating a new repository click new in the remote repository and fill out the repository key (name of your repository in Artifactory) and the URL you would like to resolve the artifacts from. Before creating the repository, go to Packages tab and check the checkbox near P2 Repository Support.

Another option is to create a virtual repository that will aggregate both your remote and local repositories.

In the Repositories section, scroll down to Virtual Repositories and create a new repository. In the P2 tab click enable and point to the right P2 repository. Artifactory will automatically create a new remote repository for that URL if it does not exist yet.

Each time you resolve an artifact, Artifactory will first check the cache and If it exists, Artifactory will provide the artifact from the cache, otherwise Artifactory will download from the URL you have provided and cache it for the next use.

For further information please visit our wiki page about P2 Repositories.