We start with describing our dependencies.
SBuild provides various options to retrieve your dependencies, out of the box.
Of course, you can reference local JARs, but you can also use Maven repositories.
In fact, you can access any resource available via HTTP protocol and can even reference resources located inside a ZIP file, which itself is located on the internet.
All your dependencies are declared in SBuilds build file, which by default has the name @SBuild.scala@. Here is an example:
import de.tototec.sbuild._
import de.tototec.sbuild.TargetRefs._
class SBuild(implicit project: Project) {
SchemeHandler("http", new HttpSchemeHandler())
SchemeHandler("mvn", new MvnSchemeHandler())
SchemeHandler("zip", new ZipSchemeHandler())
val dependencies =
"libs/a-local-jar.jar" ~
"http://cmdoption.tototec.de/cmdoption/attachments/download/3/de.tototec.cmdoption-0.1.0.jar" ~
"mvn:org.slf4j:slf4j-api:1.7.0" ~
"zip:file=junit4.10/junit-4.10.jar;archive=http://cloud.github.com/downloads/KentBeck/junit/junit4.10.zip"
ExportDependencies("eclipse.classpath", dependencies)
}
Above, you see a minimal SBuild build file with four declared dependencies. Each of them uses a different name scheme.
The first one (line 11) uses the "file" scheme, which is the default and therefore the prefix "file:" is (and can) omitted.
The second one (line 12) uses the "http" scheme, which is registered in line 6, and used the HTTP protocol to download dependencies. (The HttpSchemeHandler
is used.)
The third dependency (line 13) used the "mvn" scheme, registered in line 7, which allows you to access resources in Maven repositories through the typical Group:Artifact:Version
coordinates.
Per default, the central Maven repository is used, but you can configure the MvnSchemeHandler
further, to e.g. add more repositories.
The fourth dependency (line 14) is a file inside a ZIP file and uses the "zip" scheme, registered in line 8, to access it.
The file=<name>
part describes the file inside ZIP file.
The archive=<archive>
part describes the location of the ZIP file, which may be any of the supported schemes, here the "http" scheme was used. (The ZipSchemeHandler
is used.)
Finally, you want to access your dependencies from Eclipse, so we export them in line 16 and thus make it accessible from the SBuild Eclipse Plugin.
Each of the SchemeHandler registered above can be further customized.
The name you give to your scheme is up to you, as long it is unique and is not "file" or "phony", which are the built-in schemes of SBuild.
You can even register the same SchemeHandler under different scheme names, e.g. to have two different configurations. Here is an example:
// Maven artifacts with OSGi bundles maintained by Springsource
SchemeHandler("mvn-osgi", new MvnSchemeHandler(repos =
Seq("http://repository.springsource.com/maven/bundles/release", "http://repository.springsource.com/maven/bundles/external")))
val osgiDependencies = "mvn-osgi:org.slf4j:com.springsource.slf4j.api:1.6.1"