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).
[repositories] local my-ivy-proxy-releases: http://<host>:<port>/artifactory/<repo-key>/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] my-maven-proxy-releases: http://<host>:<port>/artifactory/<repo-key>/
Where <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:
[repositories] local my-ivy-proxy-releases: http://localhost:8081/artifactory/sbt-ivy-proxy/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] my-maven-proxy-releases: http://localhost:8081/artifactory/sbt-maven-proxy/
Proxying Maven and Ivy repositories separately
We recommend using different repositories to proxy Maven and Ivy repositories as a best practice described in Proxying Ivy Repositories in the SBT Reference Manual.
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:
-Dsbt.override.build.repos=true
You can also add this setting to your /usr/local/etc/sbtopts
( C:\Program Files (x86)\sbt\conf\sbtopts
on Windows)
For more details on SBT proxy repositories, please refer to Proxy Repositories in the SBT Reference Manual.