使用本地maven私服加速sbt下载

公司使用JFrog Artifactory搭建maven私服,配置sbt使用maven私服下载。

首先在~/.sbt/repositories中添加local-maven为公司内部maven私服地址,如果没有此文件,需要先创建。

1
2
3
4
5
6
7
8
9
~ ➤ cat ~/.sbt/repositories
[repositories]
local
local-maven: http://${your-maven-address}/artifactory/libs-release/
central: http://repo2.maven.org/maven2/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-central
sonatype-oss-snapshots

如果使用idea作为开发工具,修改Preference -> Build, Execution, Deployment -> Build Tools -> SBT中修改JVM Options,添加-Dsbt.override.build.repos=true,这样自定义的resolvers会被~/.sbt/repositories中配置覆盖。

参考:

  1. JFrog: SBT Repositories
  2. Github项目Repox:改善sbt解决依赖的速度