Nexus配置
参考sbt官网文档,将ivy和maven库区分开,如图:
The most common mistake made when setting up a proxy repository for sbt is the attempting to merge both maven and ivy repositories into the same proxy repository. While some repository managers will allow this, it’s not recommended to do so.
新增两个proxy仓库
Type | Name | Url |
---|---|---|
proxy | ivy-releases | http://repo.typesafe.com/typesafe/ivy-releases/ |
proxy | sbt-plugin-releases | http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/ |
新增一个group仓库
Type | Name | Members |
---|---|---|
group | ivy-public | ivy-releases, sbt-plugin-releases |
加上Nexus自带的Maven库,我们有了两个group:
Activator配置
Activator会在当前用户下产生~/.activator
, ~/.sbt
, ~/.ivy
3个目录。
在~/.sbt目录下新建repositories配置文件,添加如下内容:
[repositories]
activator-launcher-local: file://${activator.local.repository-${activator.home-${user.home}/.activator}/repository}, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
activator-local: file://${activator.local.repository-/Users/pandeng/Documents/_App/activator-dist-1.3.10/repository}, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
my-ivy-proxy-releases: http://192.168.1.1:8081/repository/ivy-public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
my-maven-proxy-releases: http://192.168.1.1:8081/repository/maven-public/
看看效果
添加一个新的依赖:
libraryDependencies += "org.scala-tools" % "scala-stm_2.9.1" % "0.3"
使用activator命令试试,注意带上参数-Dsbt.override.build.repos=true。
$ activator compile -Dsbt.override.build.repos=true
可以看到依赖解析已经走到我们自己的Nexus库了:
[info] Resolving jline#jline;2.12.1 ...
[info] downloading http://192.168.1.1:8081/repository/maven-public/org/scala-tools/scala-stm_2.9.1/0.3/scala-stm_2.9.1-0.3.jar
[info] [SUCCESSFUL ] org.scala-tools#scala-stm_2.9.1;0.3!scala-stm_2.9.1.jar (1731ms)
[info] downloading http://192.168.1.1:8081/repository/maven-public/org/scalatest/scalatest_2.9.1/1.6.1/scalatest_2.9.1-1.6.1.jar ...
[info] [SUCCESSFUL ] org.scalatest#scalatest_2.9.1;1.6.1!scalatest_2.9.1.jar (3603ms)
[info] Done updating.
回过头再看maven-central库,jar包已经缓存好了:
待续
笔者通过在~/.activator/activatorconfig.txt
配置文件中添加-Dsbt.override.build.repos=true
的方式并没有生效,不知什么原因,有时间再试试···