sbt 0.11:使用公司Maven存储库 [英] sbt 0.11: Using a corporate maven repository

查看:75
本文介绍了sbt 0.11:使用公司Maven存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How can a corporate Maven repository be used (to the exclusion of other repositories) with sbt 0.11.x, as described in how do I get sbt to use a local maven proxy repository (Nexus)? ? There is no mention of ivyRepositories in the new sbt wiki at github, so I'm assuming the accepted solution there is out of date.

推荐答案

步骤1:按照

Step 1: Follow the instructions at Detailed Topics: Proxy Repositories, which I have summarised and added to below:

  1. (如果使用的是Artifactory,则可以跳过此步骤.)在公司Maven存储库中创建一个完全独立的 Maven代理存储库(或组),以代理 ivy样式的存储库,例如这两个重要的存储库:

  1. (If you are using Artifactory, you can skip this step.) Create an entirely separate Maven proxy repository (or group) on your corporate Maven repository, to proxy ivy-style repositories such as these two important ones:

  • http://repo.typesafe.com/typesafe/ivy-releases/
  • http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/

这是必需的,因为某些存储库管理器无法处理混合在一起的Ivy风格的存储库和Maven风格的存储库.

This is needed because some repository managers cannot handle Ivy-style and Maven-style repositories being mixed together.

创建一个文件repositories,列出您的主要公司存储库以及您在步骤1中创建的任何其他存储库,格式如下:

Create a file repositories, listing both your main corporate repository and any extra one that you created in step 1, in the format shown below:

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

  • 要么将该文件保存在主目录内的.sbt目录中,要么在sbt命令行上指定(您需要指定是否具有

  • Either save that file in the .sbt directory inside your home directory, or specify it on the sbt command line (you will need to specify if you have disabled sharing):

    sbt -Dsbt.repository.config=<path-to-your-repo-file>
    

  • 对于使用旧版本sbt的用户来说是个好消息:即使至少在sbt 0.12.0启动器jar中,旧sbt版本的启动属性文件也不包含必需的行(提到repository.config的那个),如果您编辑这些文件以添加所需的行,然后将其重新打包到sbt 0.12.0启动器jar中,则该版本仍适用于sbt的那些版本!这是因为该功能是在启动器中实现的,而不是在sbt中实现的.据说sbt 0.12.0启动器能够启动所有版本的sbt,从0.7开始!

    Good news for those using older versions of sbt: Even though, in the sbt 0.12.0 launcher jar at least, the boot properties files for older sbt versions don't contain the required line (the one that mentions repository.config), it will still work for those versions of sbt if you edit those files to add the required line, and repackage them into the sbt 0.12.0 launcher jar! This is because the feature is implemented in the launcher, not in sbt itself. And the sbt 0.12.0 launcher is claimed to be able to launch all versions of sbt, right back to 0.7!

    第2步:要确保未使用外部存储库,请从解析器中删除默认存储库.可以通过以下三种方式之一完成此操作:

    Step 2: To make sure external repositories are not being used, remove the default repositories from your resolvers. This can be done in one of three ways:

    1. 添加上面详细主题"页面上提到的命令行选项-Dsbt.override.build.repos=true.这将导致您在文件中指定的存储库覆盖在任何sbt文件中指定的任何存储库.不过,这可能仅在sbt 0.12及更高版本中有效-我尚未尝试过.
    2. 具有与1相同的效果,可以使用overrideBuildResolvers := true,其优点是可以根据定义它的范围(项目/ThisBuild/Global)来控制适用的项目. in.在sbt 0.13中有效.
    3. 在构建文件中使用fullResolvers := Seq( 解析程序作为公司Maven存储库 ),而不是resolvers ++=resolvers :=或以前使用的任何文件.
    1. Add the command line option -Dsbt.override.build.repos=true mentioned on the Detailed Topics page above. This will cause the repositories you specified in the file to override any repositories specified in any of your sbt files. This might only work in sbt 0.12 and above, though - I haven't tried it yet.
    2. Having the same effect as 1, you can use overrideBuildResolvers := true, with the advantage that you can control the projects where it is applicable, depending on which scope (a project / ThisBuild / Global) you define it in. This works in sbt 0.13.
    3. Use fullResolvers := Seq( resolver(s) for your corporate maven repositories ) in your build files, instead of resolvers ++= or resolvers := or whatever you used to use.

    最后,请注意sbt启动器脚本在读取sbtopts文件时有一个错误,因此,如果您决定在其中放置常用的sbt命令行选项,请确保文件的最后一行以换行符结尾(特别是Emacs可能无法确保这一点,除非进行配置.)

    Finally, note that the sbt launcher script has a bug in reading the sbtopts file, so if you decide to put your common sbt command-line options in there, make sure the last line of the file ends in a newline (Emacs in particular can fail to ensure this, unless configured to do so).

    这篇关于sbt 0.11:使用公司Maven存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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