Reputation: 318
Can somebody explain the syntax for Build.scala in detail? For example, I have the following Build.scala
:
import sbt._
import Keys._
import play.Project._
object Build extends sbt.Build {
val appName = "myapp"
val appVersion = "1.0"
val appDependencies = Seq(
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
javaCore,
javaJdbc,
javaEbean,
"org.json" %"org.json" % "chargebee-1.0",
"org.reflections" % "reflections" % "0.9.8",
"org.mockito" % "mockito-all" % "1.9.5" % "test"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
libraryDependencies += "com.jolbox" % "bonecp" % "0.8.0-rc2-SNAPSHOT",
resolvers += Resolver.url("sbt-plugin-snapshots", new URL("http://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots/"))(Resolver.ivyStylePatterns),
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
)
}
How do I match the appDependencies
with the resolvers
? Or how do I know what resolvers
I need to add for what appDependencies
? Where do I look in the resolver's repo? What is libraryDependencies
? How are they different from appDependencies
?
Thanks.
Upvotes: 1
Views: 2188
Reputation: 30300
There are a few things we need to disentangle here.
Let's first distinguish between an sbt build file and Build.scala
. While the build file is exactly like a Maven pom or a Gradle build file, think of Build.scala
as a build capability with the full power and expressiveness of Scala because it is a Scala class like any other. I believe the gap between the two has narrowed though with the latest version of sbt.
Now in both sbt and Build.scala
, you have the notion of library dependencies, which are the jar libraries containing code you can use for your projects. These libraries can be found in lots of places--Maven repositories, the local file system, etc. You use resolvers to specify those locations.
So you tell both which jars you need and where to find them.
As for appDependencies
, that's not actually a thing. As I said, Build.scala
is a class like any other, and appDependencies
is just a variable name. It just makes sense to use that name because that Seq
is what you will pass to the Project
constructor.
Upvotes: 4