本地设置(每个用户,而不是版本控制)应该放在SBT的较新版本(0.10+)中? [英] Where should local settings (per user, and not version-controlled) go in newer (0.10+) versions of SBT?

查看:148
本文介绍了本地设置(每个用户,而不是版本控制)应该放在SBT的较新版本(0.10+)中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SBT构建的应用程序需要特定于主机系统的特定设置(甚至可能没有明智的默认值)。在我的特定情况下,我在谈论一个第三方软件的位置,需要构建的依赖库(虽然有很多其他用例)。这些设置不应该受版本控制,因此他们不能进入 build.sbt project / build.scala

My application which is built using SBT requires particular settings that are specific to the host system (and may not even have sensible defaults). In my particular case I'm talking about the location of a piece of third-party software with dependent libraries required for the build (although there are plenty of other use cases for this). These settings should not be version-controlled, so they can't go into build.sbt or project/build.scala which should usually be in a VCS and applicable to all checkouts of the project.

在旧版本的SBT(回到0.7.7),可以< a href =http://www.scala-sbt.org/0.7.7/docs/Properties.html =nofollow>使用默认值定义属性,可以由用户在文件中设置 build.properties (此代码在SBT源中仍然存在,顺便说一下,但它似乎不可用)。这将为我做的工作(尽管缺乏强力打字),但不再是一个选择。我想知道什么是更现代的替代方法,这可能是共同的任务是

In older versions of SBT (way back at 0.7.7) it was possible to define properties with defaults which could be set by the user in a file build.properties (this code still exists in the SBT source, incidentally, but it doesn't seem to be usable). That would do the job for me (despite the lack of strong typing) but is no longer an option. I'm wondering what the more modern alternative for this presumably common task is.

推荐答案

出乎意料的是,这个答案是非常简单的,一旦你知道。嵌入在SBT文档的最佳实践部分(这看起来有点奇怪的地方)本地设置部分

It took surprisingly to work this out, but that answer is very straightforward once you know. Buried in the "Best Practices" section of the SBT documentation (this seems a slightly strange spot for it) is a section on "Local settings":


将设置放在未检入版本控制的项目中的.sbt文件中,例如/local.sbt。 sbt结合了多个.sbt文件的设置,所以你仍然可以有标准的/build.sbt并检查到版本控制。

Put settings in a .sbt file in a project that isn't checked into version control, such as /local.sbt. sbt combines the settings from multiple .sbt files, so you can still have the standard /build.sbt and check that into version control.

简单!当然,您首先需要向您的项目添加任何自定义的用户可设置的设置。为此,请查看这个答案(原来的问题是关于插件,但答案在那里只是一个单一的项目),这是对 SBT文档的非常有用的补充该主题不像IMO那么清楚。

Simple! You'll first need to add any custom user-settable settings to your project of course. For that, check out this SO answer (the original question is about plugins, but the answer there works fine for just a single project) which is a very helpful addition to the SBT documentation on the subject which is not quite as clear as it could be IMO.

这篇关于本地设置(每个用户,而不是版本控制)应该放在SBT的较新版本(0.10+)中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆