如如何获取sbt以使用本地maven代理存储库(Nexus)??在github上的新sbt Wiki中没有提及ivyRepositories,所以我假设那里接受的解决方案已经过时.
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:
(如果使用的是Artifactory,则可以跳过此步骤.)在公司Maven存储库中创建一个完全独立的 Maven代理存储库(或组),以代理 ivy样式的存储库,例如这两个重要的存储库:
(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:
- repo.typesafe/typesafe/ivy-releases/
- repo.scala-sbt/scalasbt/sbt-plugin-releases/
- repo.typesafe/typesafe/ivy-releases/
- repo.scala-sbt/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: repo.example/maven-releases/ my-ivy-proxy-releases: repo.example/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:
最后,请注意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存储库
发布评论