aboutsummaryrefslogtreecommitdiff
path: root/stage2/BasicBuild.scala
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-03-12 16:06:14 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2016-03-12 16:06:14 -0500
commit906db6c55289d9aba5da824d5f2f3d2cae70813e (patch)
tree1b5fea4598ede93c60f9940b6776f2a0506daa46 /stage2/BasicBuild.scala
parentb143c01a2e180b647eb27338cb7302aa38ef10c6 (diff)
downloadcbt-906db6c55289d9aba5da824d5f2f3d2cae70813e.tar.gz
cbt-906db6c55289d9aba5da824d5f2f3d2cae70813e.tar.bz2
cbt-906db6c55289d9aba5da824d5f2f3d2cae70813e.zip
Improved how to express dependencies
Add - Constructor syntax for cross-scala-version dependencies (as rightfully requested on reddit) and encouraged over SBT's still supported operator syntax - Add support for classifiers other than "sources"
Diffstat (limited to 'stage2/BasicBuild.scala')
-rw-r--r--stage2/BasicBuild.scala25
1 files changed, 18 insertions, 7 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index bee58dd..f8431ea 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -35,7 +35,7 @@ class Build(val context: Context) extends Dependency with TriggerLoop{
// ========== meta data ==========
def scalaVersion: String = constants.scalaVersion
- final def scalaMajorVersion: String = scalaVersion.split("\\.").take(2).mkString(".")
+ final def scalaMajorVersion: String = lib.scalaMajorVersion(scalaVersion)
def zincVersion = "0.3.9"
def dependencies: Seq[Dependency] = Seq(
@@ -80,14 +80,25 @@ class Build(val context: Context) extends Dependency with TriggerLoop{
}
assertSourceDirectories()
-
- /** SBT-like dependency builder DSL */
- class GroupIdAndArtifactId( groupId: String, artifactId: String ){
- def %(version: String) = new MavenDependency(groupId, artifactId, version)(lib.logger)
+ def ScalaDependency(
+ groupId: String, artifactId: String, version: String, classifier: Classifier = Classifier.none,
+ scalaVersion: String = scalaMajorVersion
+ ) = lib.ScalaDependency( groupId, artifactId, version, classifier, scalaVersion )
+
+ /** SBT-like dependency builder DSL for syntax compatibility */
+ class DependencyBuilder2( groupId: String, artifactId: String, scalaVersion: Option[String] ){
+ def %(version: String) = scalaVersion.map(
+ v => ScalaDependency(groupId, artifactId, version, scalaVersion = v)
+ ).getOrElse(
+ JavaDependency(groupId, artifactId, version)
+ )
}
implicit class DependencyBuilder(groupId: String){
- def %%(artifactId: String) = new GroupIdAndArtifactId( groupId, artifactId++"_"++scalaMajorVersion )
- def %(artifactId: String) = new GroupIdAndArtifactId( groupId, artifactId )
+ def %%(artifactId: String) = new DependencyBuilder2( groupId, artifactId, Some(scalaMajorVersion) )
+ def %(artifactId: String) = new DependencyBuilder2( groupId, artifactId, None )
+ }
+ implicit class DependencyBuilder3(d: JavaDependency){
+ def %(classifier: String) = d.copy(classifier = Classifier(Some(classifier)))
}
final def BuildDependency(path: File) = cbt.BuildDependency(