Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "str" % "str" mean in SBT?

Tags:

scala

sbt

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.

like image 433
Aaron Yodaiken Avatar asked Mar 10 '11 23:03

Aaron Yodaiken


1 Answers

It declares a dependency. In particular,

val scalatest = "org.scalatest" % "scalatest" % "1.0.1-for-scala-2.8.0.RC1-SNAPSHOT

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 % on String, but, for the record, it is found on ManagedProject, converting a String into a GroupID. In the same trait there's also another implicit which enables the at method.

At any rate, the implicit will turn the first String into a GroupID, the first % will take a String representing the artifact ID and return a GroupArtifactID, and the second will take a String representing the revision and return a ModuleID, which is what finally gets assigned to scalatest.

like image 153
Daniel C. Sobral Avatar answered Oct 04 '22 02:10

Daniel C. Sobral