如何更改 SBT 为 Maven 存储库生成 URL 的规则?
默认情况下,Scala 内置工具 (SBT) 有一组关于在查找依赖项时如何生成 URL 的规则。例如,如果我有以下构建文件,
// Project settings
name := "MyProject"
version := "0.1"
organization := "com.me"
scalaVersion := "2.8.1"
// Dependencies
libraryDependencies ++= Seq(
"com.google.guava" %% "guava" % "r09"
)
// Repositories
resolvers += "Maven Central Server" at "http://repo1.maven.org/maven2"
那么 SBT 会尝试在以下 URL 中查找 guava,
http://repo1.maven.org/maven2/com/google/guava/guava_2.8.1/r09/guava_2.8.1-r09.pom
但是,在这种情况下我要查找的库甚至不是为 Scala 制作的,因此组合 Scala 版本不会这里没有道理。我如何告诉 SBT 生成用于 Maven 存储库的 URL 的格式是什么?
编辑
虽然看起来可以像这样编辑布局,但
Resolver.url("Primary Maven Repository",
new URL("http://repo1.maven.org/maven2/"))( Patterns("[organization]/[module]/[module]-[revision].[ext]") )
“[module]”关键字被预定义为 (artifact id)_(scala version) 和“[artifact]”关键字只是“ivy”,让我回到了第一个方向。
By default, the Scala Built Tool (SBT) has a set of rules on how to generate URLs when looking up dependencies. For example, if I have the following build file,
// Project settings
name := "MyProject"
version := "0.1"
organization := "com.me"
scalaVersion := "2.8.1"
// Dependencies
libraryDependencies ++= Seq(
"com.google.guava" %% "guava" % "r09"
)
// Repositories
resolvers += "Maven Central Server" at "http://repo1.maven.org/maven2"
Then SBT attempts to find guava at the following URL,
http://repo1.maven.org/maven2/com/google/guava/guava_2.8.1/r09/guava_2.8.1-r09.pom
However, the library I'm looking for in this case isn't even made for Scala, so combining the Scala version just doesn't make sense here. How can I tell SBT what the format is for generating URLs for use with Maven repositories?
EDIT
While it seems that it is possible to edit the layout like so,
Resolver.url("Primary Maven Repository",
new URL("http://repo1.maven.org/maven2/"))( Patterns("[organization]/[module]/[module]-[revision].[ext]") )
the "[module]" keyword is predefined to be the (artifact id)_(scala version) and the "[artifact]" keyword is just "ivy", leaving me back at square one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我记得“%%”附加了scala版本,而“%”则没有。尝试
As far as I remember "%%" appends the scala version and "%" does not. Try
查看官方
sbt
wiki 的最后一段(自定义布局)此处。基本上,SBT 允许您使用以下语法:
Check last one paragraph (Custom Layout) of official
sbt
wiki here.Basically SBT allows you to use this syntax: