Skip to main content

Conan Repositories

Introduction

Conan is a decentralized, portable, extensible, and stable package manager for C/C++ projects with a client-server architecture. Conan allows encapsulation of C/C++ project dependencies, distribution of them, and consumes them in other projects. This involves the complex challenges of transitive dependencies, versioning, licensing, and more. It works across Linux, OSX, and Windows platforms.

Supported Features

Versions

Sonatype Nexus Repository requires Conan version 1.x.

Repository Types

  • Proxy repositories

  • Hosted repositories (PostgreSQL or H2 database required) PRO

Conan Revisions

Note

Only available in Sonatype Nexus Repository Pro. Interested in a free trial? Start here.

What are Revisions?

In simplest terms, revisions are versions of versions. The Conan revisions feature allows you to make changes to your artifacts while maintaining a single Conan reference. Every Conan recipe export is associated with a unique ID (i.e., a revision); every recipe change results in a new recipe revision (RREV). Whenever you create a new package, Conan calculates a new package revision (PREV) using the package contents' hash. Package revisions belong to recipe revisions; the same package ID may have multiple package revisions belonging to a single recipe revision. See theConan documentation for detailed information about the revisions feature.

Requirements and Limitations

  • Hosted repositories only

  • Must be using H2 or PostgreSQL database

  • You must add the Conan Bearer Token Realm in Nexus Repository (See our Realms documentation).

  • You must explicitly enable revisions for Conan as detailed in the Conan documentation.

Proxying Conan Repositories

Complete the following steps to set up a Conan proxy repository to access a remote repository location:

  1. Create a new Conan proxy repository as documented in Repository Management

    1. Minimal configuration steps are as follows:

      1. Define a Name

      2. Define a URL for Remote storage (e.g., https://center.conan.io, which is the default)

      3. Select a Blob storeforStorage

  2. If you will use HTTPS protocol for Conan and your Nexus Repository is configured to use a self-signed certificate, add your certificate to the trusted list:

    1. Add the certificate to <user_home>/.conan/cacert.pem

    2. Note that this is a simple .txt file

  3. Enable the Conan Bearer Token Realm

    1. Navigate to AdministrationSecurityRealms

    2. Add the Conan Bearer Token Realm as described in Realms

Using a Hosted Conan Repository PRO

Conan-hosted repositories will only work with H2 or PostgreSQL databases.

Complete the following steps to set up a Conan-hosted repository:

  1. Create a new hosted Conan repository in Nexus Repository as documented in Repository Management.

  2. Enable the Conan Bearer Token Realm

    1. Navigate to AdministrationSecurityRealms

    2. Add the Conan Bearer Token Realm as described in Realms

Below is an example of using a hosted Conan repository:

    conan remote add conan-hosted $HOSTED_REPO_URL
    conan remote login [repo user] -p [repo password]
    conan new hello/0.1
    conan create . hello/world
    conan upload hello/0.1@hello/world --all -r=conan-hosted

Conan Client Configuration to Work with Nexus Repository

To avoid bypassing the Conan repository and stop Conan package installation directly from remote servers, delete the default remotes. To delete any remote server, use the following command where <remote name> is the remote's name:

conan remote remove <remote name>

For example, use the following to delete the default remote:

conan remote remove conan-center

To add a new remote with a link to the Conan repository, use the following command:

conan remote add <remote name> <remote URL> <SSL flag>
  • <remote name> is the Conan repository name

  • <remote URL> is the Conan repository URL

  • <SSL flag> set to "true" to enable HTTPS protocol or "false" to enable HTTP protocol

For example, the following command adds a Conan proxy repository with the name conan-proxy:

conan remote add conan-proxy http://localhost:8081/repository/conan-proxy/ false

The following command changes the remote configuration (changes the remote URL or enables/disables SSL):

conan remote update <remote name> <remote URL> <SSL flag>

You can review a list of configured remotes by using the following command:

conan remote list

Content Selectors and Conan

When configuring content selectors for a Conan repository, it is necessary to use two paths in your content selector definition as Conan uses the following two paths:

  • /repository/conan-releases/v1/conans/<package-name>/<version>/<user>/<stable>/upload_urls

  • /repository/conan-releases/conans/<user>/<package-name>/<version>/<stable>/conanmanifest.txt or /repository/conan-releases/conans/<user>/<package-name>/<version>/<stable>/conanfile.py

Below is an example content selector for a Conan hosted repository:

format == "conan" and (path =~ ".*/<package-name>/.+/<user>/<stable>/.*" or path =~ ".*/<user>/<package-name>/.+/<stable>/.*")