scala 在 IntelliJ IDEA 中更改 sbt 项目的常春藤缓存位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23845357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 06:16:52  来源:igfitidea点击:

Changing Ivy Cache Location for sbt projects in IntelliJ IDEA?

scalaintellij-ideasbt

提问by SMPH

I have sbt 0.13.2 with a Scala project in IntelliJ 13.0.2.

我在 IntelliJ 13.0.2 中有一个带有 Scala 项目的 sbt 0.13.2。

I just want to change my default ../.ivy2/cachepath.

我只想更改我的默认../.ivy2/cache路径。

I tried to change following entry in ../bin/sbtfile in SBT installation

我试图../bin/sbt在 SBT 安装中更改文件中的以下条目

-Dsbt.ivy.home=D:/IvyHome/.ivy

But no luck.

但没有运气。

enter image description here

在此处输入图片说明

Even in the IDE I couldn't find the place to update SBT_HOME

即使在IDE中我也找不到更新的地方 SBT_HOME

What would be the solution?

解决办法是什么?

enter image description here

在此处输入图片说明

回答by lpiepiora

First of all you have two SBT plugins. The version of Scala plugin you're using already supports SBT, and you don't need an extra plugin. I recommend that you start by removing the extra plugin.

首先,您有两个 SBT 插件。您使用的 Scala 插件版本已经支持 SBT,您不需要额外的插件。我建议您首先删除额外的插件。

Two Plugins

两个插件

Remove unofficial plugin

删除非官方插件

To remove the unofficial plugin go to pluginsconfiguration and remove the check next to the SBT plugin. This will not remove the plugin completely, but will keep it disabled.

要删除非官方插件,请转到插件配置并删除 SBT 插件旁边的检查。这不会完全删除插件,但会使其保持禁用状态。

Disable Plugin

禁用插件

Change the cache location

更改缓存位置

Once you have only single plugin, you can modify the location of the cache, by going to options, and searching for sbt. You should find an entry in IDE Settings.

一旦您只有一个插件,您就可以修改缓存的位置,方法是转到选项并搜索sbt。您应该在IDE Settings 中找到一个条目。

IDE Settings

IDE 设置

You should see the VM Parameters. Click the icon next to the input, and add -Dsbt.ivy.home=D:/IvyHome/.ivyin the last line.

您应该会看到VM 参数。单击输入旁边的图标,并-Dsbt.ivy.home=D:/IvyHome/.ivy在最后一行添加。

Modify Settings

修改设置

Click OKand restart the IDE after saving all settings.

保存所有设置后,单击“确定”并重新启动 IDE。

Now you should be using the new home location (of course this is true only for the builds run from IDE, if you use SBT from console, it will still use an old home setting).

现在您应该使用新的 home 位置(当然这仅适用于从 IDE 运行的构建,如果您从控制台使用 SBT,它仍将使用旧的 home 设置)。

Change the cache location for SBT ran from Console

更改从控制台运行的 SBT 的缓存位置

As pointed out in the paragraph above. This change will not effect SBT ran from console. This is because by default IntelliJ uses bundled SBT.

正如上一段所指出的。此更改不会影响从控制台运行的 SBT。这是因为默认情况下 IntelliJ 使用捆绑的 SBT。

If you want to modify your Ivy home for sbt, which you run from console, you have several ways of doing that.

如果您想为从控制台运行的 sbt 修改您的 Ivy 主页,您有几种方法可以做到这一点。

I think the simplest is to modify the sbtconfig.txtfile in the SBT_HOME/conf/sbtconfig.txt(Windows only - on Linux you'd have to modify sbtopts).

我认为,最简单的就是修改sbtconfig.txt的文件SBT_HOME/conf/sbtconfig.txt(仅适用于Windows -在Linux上你必须修改sbtopts)。

At the end of the file add -Dsbt.ivy.home=D:/IvyHome/.ivy.

在文件末尾添加-Dsbt.ivy.home=D:/IvyHome/.ivy.

The other way would be to modify Launcher Configuration as described in the documentation

另一种方法是按照文档中的描述修改启动器配置

回答by smbikina

I had the same issue with IntelliJ IDEA 14 Build 139.463.4 (Play Framework 2.2.5 project).

我在 IntelliJ IDEA 14 Build 139.463.4(Play Framework 2.2.5 项目)上遇到了同样的问题。

I followed the steps below but it did not work for me. I finally fixed the issue by adding to the VM Parameters of the SBT Runner : -Duser.home=D:/Users/myName/ .

我按照以下步骤操作,但它对我不起作用。我最终通过添加到 SBT Runner 的 VM 参数解决了这个问题: -Duser.home=D:/Users/myName/ 。

The variable user.home is used by the SBT Launcher to build ivy-home variable.

SBT Launcher 使用变量 user.home 来构建 ivy-home 变量。

回答by Minnie Shi

The answer suggesting changing IDE settings essentially changed the file.idea/sbt.xml(if you made changes for the project), or C:\Users\***\.IdeaIC14\config\options\project.default.xml(if you made changes for the IDE default regardless which project).

建议更改 IDE 设置的答案实际上更改了文件.idea/sbt.xml(如果您对项目进行了更改),或者C:\Users\***\.IdeaIC14\config\options\project.default.xml(如果您对 IDE 默认值进行了更改,而不管哪个项目)。

Therefore, you may consider putting this file in source control if you need to change it frequently. (In my case I had to switch between the Spark 1.4and Spark 1.5libraries, making this worthwhile.)

因此,如果您需要经常更改它,您可以考虑将此文件置于源代码管理中。(就我而言,我不得不在Spark 1.4Spark 1.5库之间切换,这很值得。)