来自sbt官方文档中的Command Line Options:
-
sbt.global.base - 包含全局设置和插件的目录(默认:~/.sbt/0.13)
-
sbt.ivy.home - 包含本地 Ivy 存储库和工件缓存的目录(默认:~/.ivy2)
似乎~/.activator 已在启动脚本中设置和使用,我将在此处更改值。
还显示(在activator-launch-1.2.1.jar 中的sbt/sbt.boot.properties 中)ivy-home 的值是${user.home}/.ivy2:
[ivy]
ivy-home: ${user.home}/.ivy2
checksums: ${sbt.checksums-sha1,md5}
override-build-repos: ${sbt.override.build.repos-false}
repository-config: ${sbt.repository.config-${sbt.global.base-${user.home}/.sbt}/repositories}
这意味着没有一些开发就只能更改sbt.global.base。
➜ minimal-scala activator -Dsbt.global.base=./sbt -Dsbt.ivy.home=./ivy2 about
[info] Loading project definition from /Users/jacek/sandbox/sbt-launcher/minimal-scala/project
[info] Set current project to minimal-scala (in build file:/Users/jacek/sandbox/sbt-launcher/minimal-scala/)
[info] This is sbt 0.13.5
[info] The current project is {file:/Users/jacek/sandbox/sbt-launcher/minimal-scala/}minimal-scala 1.0
[info] The current project is built against Scala 2.11.1
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4
如果您想深入了解,可以使用 consoleProject 命令查询 sbt 和 Ivy 的主目录的当前值(假设您以 activator -Dsbt.global.base=./sbt -Dsbt.ivy.home=./ivy2 启动 activator):
> consoleProject
[info] Starting scala interpreter...
[info]
import sbt._
import Keys._
import _root_.sbt.plugins.IvyPlugin
import _root_.sbt.plugins.JvmPlugin
import _root_.sbt.plugins.CorePlugin
import _root_.sbt.plugins.JUnitXmlReportPlugin
import currentState._
import extracted._
import cpHelpers._
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_60).
Type in expressions to have them evaluated.
Type :help for more information.
scala> appConfiguration.eval.provider.scalaProvider.launcher.bootDirectory
res0: java.io.File = /Users/jacek/sandbox/sbt-launcher/minimal-scala/sbt/boot
scala> appConfiguration.eval.provider.scalaProvider.launcher.ivyHome
res1: java.io.File = /Users/jacek/.ivy2
如果你真的想说服 Activator 使用sbt.ivy.home,你必须将sbt/sbt.boot.properties 更改为activator-launch-1.2.2.jar。只需按照以下步骤操作:
-
从activator-launch-1.2.2.jar 中解压sbt/sbt.boot.properties。
jar -xvf activator-launch-1.2.2.jar sbt/sbt.boot.properties
-
编辑sbt/sbt.boot.properties并将ivy-home替换为[ivy]。
ivy-home: ${sbt.ivy.home-${user.home}/.ivy2}
-
将更改后的sbt/sbt.boot.properties 添加到activator-launch-1.2.2.jar。
jar -uvf activator-launch-1.2.2.jar sbt/sbt.boot.properties
随着更改,-Dsbt.ivy.home=./ivy2 工作正常。
scala> appConfiguration.eval.provider.scalaProvider.launcher.bootDirectory
res0: java.io.File = /Users/jacek/sandbox/sbt-launcher/minimal-scala/sbt/boot
scala> appConfiguration.eval.provider.scalaProvider.launcher.ivyHome
res1: java.io.File = /Users/jacek/sandbox/sbt-launcher/minimal-scala/ivy2