Pub Repositories

JFrog Artifactory Documentation

ft:sourceType
Paligo

Overview

From JFrog Artifactory 7.31.10, the Pub repository is supported for the Dart programming language, which contains reusable libraries & packages for Flutter, Angular Dart, and general Dart programs. This gives you full control of your deployment and resolving of Pub packages. Pub downloads your Dart package's dependencies, compiles your packages, makes distributable packages, and uploads them to pub.dev, the Dart community’s package registry. You can contribute to this book on GitHub.

About Dart Programming Language

Dart is an Open Source, client-side programming language developed by Google, which is designed for client development, such as web and mobile apps. Dart is an object-oriented, class-based, garbage-collected language with a C-style syntax, and can also be used to build server and desktop applications.

Flutter is an Open-Source UI SDK also developed by Google. It allows the development of iOS/Android apps and uses Dart as its programming language.

Pub repositories in Artifactory offer the following benefits:

  • Secure and private local Pub repositories with fine-grained access control

  • The ability to serve as a proxy for remote Pub resources and to cache downloaded Pub packages to keep you independent of the network and the remote resource

  • Metadata calculation of the Pub packages hosted in the Artifactory local repositories

  • Version management: Archiving older versions of the packages uploaded to local repositories

  • Source and binary management

Supported Pub Version

Artifactory supports Pub version 2.15.0-268.8.beta and above.

Pub Repository Structure

The Pub repository structure is as follows.

|-.pub/<packageName>.json
|----<packagName>/<packageName>-<version>.tar.gz

Note the following:

  • The index of the packages will be populated under the .pub , each package has its own json file that index the package versions.

  • The binary of the library is populated under the package folder with a convention of the package name and the package version , for example: pedentic/pedantic-1.9.1.tar.gz.

Deployment Structure

All deployment of Pub packages into Artifactory must be under the <PACKAGE_NAME>/<PACKAGE_NAME>- <VERSION>.tar.gz structure.

If packages are not deployed under this structure, they will not be included in any index file.

Setting up a Pub Repository

You can set up the following repository types:

Follow the steps according to each repository type below. A Pub package (tar.gz) is deployed to a local PUB repository, and resolved using all repository types.

You can download packages from a local, remote, or virtual Pub repository.

Setting up a Local Repository

Local repositories enable you to deploy pub (tar.gz) packages. Artifactory calculates the metadata for all packages and indexes them to allow users to download these packages through the Pub client.

To create a Pub local repository, navigate to the Administration module, go to Repositories| Repositories | Local | New Local Repository and select Pub as the Package Type.

Pub_local_repo.png
Setting up a Remote Repository

Remote repositories enable you to proxy and cache Pub packages.

To specify that a Remote Repository supports Pub packages, you need to set its Package Type to Pub when it is created.

pub_new remote.png
Setting up a Virtual Repository

A Virtual Repository defined in Artifactory aggregates packages from both local and remote repositories.

This allows you to access both locally hosted Pub packages and remote proxied Pub repositories from a single URL defined for the Virtual repository.

To define a virtual Pub repository, do the following:

  1. Create a Virtual Repository, and set the Package Type to Pub.

  2. Select the underlying local and remote Pub repositories to include in the Basic settings tab.

pub_new virtual.png
Pub SemVer 2.0 Package Support

Artifactory requires applying SemVer 2.0 rules for Pub repositories, which means you can now use pre-release numbers with dot notation or add metadata to the version, for example: MyApp.3.0.0-build.60, MyApp.1.0+git.52406.

Artifactory serves the requests for downloading packages using SemVer 2.0 rules. For example, if the latest version for a certain package is in a SemVer 2.0 convention, Artifactory will return it to the client. NuGet packages with the SemVer 2.0 convention are served from local, remote, and virtual repositories and for both Pub API v2, and v3 feeds.

Configuring the Pub Client to Work with Artifactory

To use Artifactory with your Pub client, you will first need to set Artifactory as a Pub repository, and then to resolve and deploy the relevant Dart/ Flutter package.

Prerequisite

You will need to generate an authentication token. For more information, see Access Token Authorization Headers.Introduction to Access Tokens

Step 1: Add Artifactory to your / etc/pub/repositories File

  1. Navigate to Application Module | Artifactory | Artifacts.

  2. Select the desired repository.

  3. Select Set Me Up.

  4. In the Configure tab, add the repository to your client using the following command and run it.

    HTTPS-Mode Only

    Pub authentication to Artifactory is supported only through HTTPS-Only mode.