gpt4 book ai didi

sbt - 如何配置Typesafe Activator不使用用户主目录?

转载 作者:行者123 更新时间:2023-12-04 03:43:48 26 4
gpt4 key购买 nike

我想配置Typesafe Activator及其捆绑的工具,以不使用我的用户主目录-我的意思是~/.activator(配置?),~/.sbt(sbt配置?),尤其是~/.ivy2,我想在两个操作系统之间共享。
类型安全的“文档”几乎没有帮助。

需要Windows和Linux的帮助。

最佳答案

来自sbt官方文档中的Command Line Options:

  • sbt.global.base-包含全局设置和插件的目录(默认:~/.sbt/0.13)
  • sbt.ivy.home-包含本地Ivy存储库和工件缓存的目录(默认:~/.ivy2)

  • 看来 ~/.activator已在启动脚本中设置并使用,这就是我要更改值的地方。

    (在 sbt/sbt.boot.properties中的 activator-launch-1.2.1.jar中)还出现了 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启动了 activator -Dsbt.global.base=./sbt -Dsbt.ivy.home=./ivy2):
    > 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。只需按照以下步骤操作:
  • sbt/sbt.boot.properties中解压缩activator-launch-1.2.2.jar
    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

    关于sbt - 如何配置Typesafe Activator不使用用户主目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24199917/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com