A remote repository defined in Artifactory serves as a caching proxy for a registry managed at a remote URL.
Artifacts (such as JAR files) requested from a remote repository are cached on demand. You can remove downloaded artifacts from the remote repository cache, however, you can not manually deploy artifacts to a remote SBT repository.
To define a remote sbt repository to proxy a remote sbt registry follow the steps below:
- In the Administration module, under Repositories | Repositories | Remote, click New Remote Repository.
- In the New Repository dialog, set the Package Type to SBT, set the Repository Key value, and specify the URL to the remote registry in the URL field as displayed below:
- Click Save & Finish.
The parameters needed to configure remote sbt repositories are identical to those used for Maven repositories. For more details, please refer to Remote Repositories.
A Virtual Repository defined in Artifactory aggregates packages from both local and remote repositories.
This allows you to access both locally hosted JARS and remote proxied sbt registries from a single URL defined for the virtual repository.
To define a virtual sbt repository, from the Administration module, go to Repositories | Repositories | Virtual, set the Package Type to sbt, and select the underlying local and remote sbt repositories to include in the Basic settings tab.
Click Save & Finish to create the repository.
The parameters needed to configure virtual sbt repositories are identical to those used for Maven repositories. For more details, please refer to Virtual Repositories.
To configure sbt to resolve and deploy artifacts through sbt repositories defined in Artifactory, simply select one of the sbt repositories in the Application module, go to | Artifactory | Artifacts | Artifact Repository Browser and click Set Me Up. Artifactory will display code snippets you can use in the relevant sbt files.
Configuring Proxy Repositories
To configure a repository defined in Artifactory as a proxy repository for sbt, add the code snippet below to your
~/.sbt/repositories file (
C:\Users\%USERNAME%\.sbt\repositories on Windows).
<host>:<port> are the host URL and port on which Artifactory is running.
For example, if you are running Artifactory on your local machine, on port 8081, and want to proxy Ivy repositories through a repository called
sbt-ivy-proxy, and proxy Maven repositories through a repository called
sbt-maven-proxy you would use:
Proxying Maven and Ivy repositories separately
To specify that all resolvers added in the sbt project should be ignored in favor of those configured in the repositories configuration, add the following configuration option to the sbt launcher script:
You can also add this setting to your
C:\Program Files (x86)\sbt\conf\sbtopts on Windows)
Configuring Artifact Resolution
To resolve artifacts through Artifactory, simply add the following code snippet to your
<host>:<port> are the host URL and port on which Artifactory is running, and repo-key is the Artifactory repository through which you are resolving artifacts
To deploy SBT build artifacts to repositories in Artifactory, add the following code snippets to your
For releases, add:
For snapshots, add:
<host>:<port> are the host URL and port on which Artifactory is running, and repo-key is the Artifactory repository to which you are deploying artifacts.
A sample sbt project that uses Artifactory is available on GitHub and can be freely forked.