To use Artifactory with your Pub client, you will first need to set Artifactory as a Pub repository, and then deploy and resolve the relevant Dart/Flutter
package, as described in this section.
Prerequisite
You will need to generate an authentication token. For more information, see Access Token Authorization Headers.
Step 1: Add Artifactory to your /etc/pub/repositories File
Select the Platform tab and go to Artifactory->Artifacts.
Select the desired repository.
Select Set Me Up.
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.
Step 2: Deploy Dart/Flutter Packages
Dart/Flutter packages can be deployed by one of the following three methods:
With cURL
Through the User Interface (UI)
Through the Command Line Interface (CLI)
Deploy Dart/Flutter Packages using the cURL
You can deploy a Dart/Flutter package into an Artifactory repository using the cURL as follows:
curl -u<USERNAME>:<TOKEN> -T <file>.tar.gz " https://<YOUR_JFROG_DOMAIN>/artifactory/<REPO_NAME>/<PACKAGE_NAME>/<FILE>/<VERSION>.tar.gz"
Indexing Dart/Flutter Packages
For your files to be indexed properly, it is very important to ensure that all deployment of Dart/ Flutter packages into Artifactory occurs under the <REPOSITORY>/<PACKAGE_NAME/<FILE>/<VERSION>
structure. Packages deployed anywhere else will not be indexed.
Deploy Dart/Flutter Packages through the User Interface
To deploy a Dart/Flutter package to Artifactory through the UI, do the following:
Select the Platform tab and go to Artifactory->Artifacts.
Select the Pub repository where you want to deploy the packages.
Click the Deploy button in the upper right part of the screen. The Deploy window appears, as shown below.
Click Drop File or Select File in the Deploy window and select the artifact that you want to deploy.
In Target Path, you can specify the relative path for the target repository, or use the default path that Aritfactory assigns.
Click Deploy.
Deploy Dart/Flutter Packages with the CLI
In the CLI, go to your project and navigate to the directory that contains the pubspec.yaml file.
Run the following command:
dart pub publish
This publishes your Dart package to your private Artifactory Pub repository, as defined in your configuration.
Step 3: Resolve Dart/Flutter Packages
To resolve Dart packages:
In the CLI, go to your project and navigate to the directory that contains the pubspec.yaml file.
Run the following command:
dart pub get
This will fetch all dependencies defined in pubspec.yaml, including packages hosted on your private Artifactory.