Conan Repositories
Introduction
Conan is decentralized, portable, extensible and table package manager for C/C++ projects with client-server architecture. Conan allows to encapsulate C/C++ project dependencies, distribute them, and consume them in other projects. This involves the complex challenges of transitive dependencies, versioning, licensing, and so forth. It works across Linux, OSX and Window s platforms.
This format is disabled by default in Nexus Repository Pro HA-C environments.
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 PRO NEW IN 3.50.0
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 the Conan 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:
- Create a new conan proxy repository as documented in Repository Management
- Minimal configuration steps are as follows:
- Define a Name
- Define a URL for Remote storage (e.g.,
https://center.conan.io
, which is the default) - Select a Blob store for Storage
- Minimal configuration steps are as follows:
- 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:
- Add the certificate to
<user_home>/.conan/cacert.pem
- Note that this is a simple .txt file
- Add the certificate to
- Enable the Conan Bearer Token Realm
- Navigate to Administration → Security → Realms
- 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:
- Create a new hosted Conan repository in Nexus Repository as documented in Repository Management.
- Enable the Conan Bearer Token Realm
- Navigate to Administration → Security → Realms
- 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 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>/.*")