(SBT) 如何禁用默认解析器并仅使用公司内部解析器? [英] (SBT) How to disable default resolver and only use the company internal resolver?

查看:38
本文介绍了(SBT) 如何禁用默认解析器并仅使用公司内部解析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望使用公司内部的 ivy/maven 存储库(artifactory)来提高解析和下载 jar 文件的速度,并且我们希望使用它在我们组织的不同团队之间交换二进制 jar 文件.

We want to use company internal ivy/maven repository (artifactory) to improve the speed of resolving, and downloading the jar files, and also we want to use it to exchange binary jar files between different teams in our organization.

我知道我们可以通过设置 ~/.repositories 来强制 SBT 通过代理

I know we can force SBT to go through proxy by setting ~/.repositories with

[repositories]
  local
  my-ivy-proxy-releases: http://repo.alpinenow.com/artifactory/repo/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
  my-maven-proxy-releases: http://repo.alpinenow.com/artifactory/repo/

然后使用 -Dsbt.override.build.repos=true 启动 SBT.这种方法对我有用.

and then launch SBT with -Dsbt.override.build.repos=true. This method works for me.

但是,要求所有开发人员都以这种方式进行设置有点麻烦.我们想知道是否可以在 Build.scala 和 plugin.sbt 中完全覆盖默认解析器,而无需额外配置.

However, it's kind of cumbersome to ask all the developers to setup this way. We're wondering if we can override the default resolvers completely in Build.scala, and plugin.sbt without extra configuration.

到目前为止,我已经尝试了以下方法,但均未成功.

So far, I've tried the following ways without success.

1) 在 Build.scala 和 plugin.sbt 中,我都添加了

1) In both Build.scala and plugin.sbt, I added

resolvers := "Local Repo" at "http://repo.alpinenow.com/artifactory/repo/",

externalResolvers := Seq(Resolver.url("Local Repo", url("http://repo.alpinenow.com/artifactory/repo"))(Resolver.ivyStylePatterns)),

但它仍然从 typesafe 和 maven1 下载 jars.

but it still downloads the jars from typesafe and maven1.

2)然后我决定将存储库文件放入项目文件夹中,并尝试直接在plugin.sbt中添加java选项,并在Build.scala中添加

2) I then decided to put repositories file into project folder, and tried to add java option directly inside plugin.sbt, and Build.scala with

System.setProperty("-Dsbt.override.build.repos", "true"),

System.setProperty("-Dsbt.repository.config", "project/repositories"),

但它仍然不起作用.我很好奇 SBT 何时获得解析器的 java 选项,因为很明显,它在 plugin.sbt 和 Build.scala 之前.

but it still doesn't work. I'm curious when the SBT gets the java options for resolvers since obviously, it's before plugin.sbt and Build.scala.

有什么想法吗?

谢谢.

DB仔

推荐答案

如果你离开了 sbt-extras shell 脚本作为默认启动器脚本的替代品,我想您可以通过设置 ~/.repositories 并添加 -Dsbt.override.build.repos= 轻松修改它真.那么您需要做的就是确保您的开发人员使用该脚本.

If you depart from the sbt-extras shell script as a replacement for the default launcher script, I guess you could easily modify that with setting up ~/.repositories and adding -Dsbt.override.build.repos=true. Then all you need to do is ensure your developers use that script.

这篇关于(SBT) 如何禁用默认解析器并仅使用公司内部解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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