“str”是什么意思? %“str” SBT 是什么意思?
我遇到了这段代码:
import sbt._
class AProject(info: ProjectInfo) extends DefaultProject(info) {
val scalaToolsSnapshots = ScalaToolsSnapshots
val scalatest = "org.scalatest" % "scalatest" %
"1.0.1-for-scala-2.8.0.RC1-SNAPSHOT"
}
我对 scalatest 包含的内容以及 % 的作用感到非常困惑。
I came across this code:
import sbt._
class AProject(info: ProjectInfo) extends DefaultProject(info) {
val scalaToolsSnapshots = ScalaToolsSnapshots
val scalatest = "org.scalatest" % "scalatest" %
"1.0.1-for-scala-2.8.0.RC1-SNAPSHOT"
}
And I'm quite confused as to what scalatest
contains, and what the %
does.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它声明了一个依赖关系。特别
找到的依赖项
是指可以在http://scala-tools.org/repo-snapshots/org/scalatest/scalatest/1.0.1-for-scala-2.8.0.RC1-SNAPSHOT/
其中
org
之前的所有内容都指的是存储库,它是在其他地方(预)定义的。找到在
String
上启用%
的隐式并不容易,但是,为了记录,它是在ManagedProject
上找到的,将%
转换为 < code>String 转换为GroupID
。在同一个特征中,还有另一个隐式启用at
方法。无论如何,隐式会将第一个
String
转换为GroupID
,第一个%
将采用String
表示工件 ID 并返回一个GroupArtifactID
,第二个将采用一个String
表示修订并返回一个ModuleID
,这就是最终得到的分配给 scalatest。It declares a dependency. In particular,
refers to a dependency which can be found at
http://scala-tools.org/repo-snapshots/org/scalatest/scalatest/1.0.1-for-scala-2.8.0.RC1-SNAPSHOT/
Where everything before
org
refers to the repository, which is (pre-)defined elsewhere.It is not easy to find the implicit that enables
%
onString
, but, for the record, it is found onManagedProject
, converting aString
into aGroupID
. In the same trait there's also another implicit which enables theat
method.At any rate, the implicit will turn the first
String
into aGroupID
, the first%
will take aString
representing the artifact ID and return aGroupArtifactID
, and the second will take aString
representing the revision and return aModuleID
, which is what finally gets assigned toscalatest
.如果您使用 Maven,这本质上是相同的事情,只不过是使用 Scala DSL。 % 作为分隔符:
阅读更多:
http://code.google.com/p/simple-build-tool /wiki/图书馆管理
If you used Maven this is essentially the same thing but with Scala DSL. % works as a separator:
Read more:
http://code.google.com/p/simple-build-tool/wiki/LibraryManagement