diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-04-03 00:09:19 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-04-03 00:09:26 -0400 |
commit | 83d6e39764103bde44d5812aa873ed7537cc8c97 (patch) | |
tree | 60a070ef1511aa525cec9bf4c19034804b829679 /stage2/SbtDependencyDsl.scala | |
parent | 8eae49b7b0a39f23518680b56429314db3d977e1 (diff) | |
download | cbt-83d6e39764103bde44d5812aa873ed7537cc8c97.tar.gz cbt-83d6e39764103bde44d5812aa873ed7537cc8c97.tar.bz2 cbt-83d6e39764103bde44d5812aa873ed7537cc8c97.zip |
Implement alternative resolvers
This commit also
- requires Dependencies to explicitly implement canBeCached
- unifies some logic for dependency downloading
- moves SBT-like dependency DSL into its own trait
- error message showing build directory for exceptions in builds
Not splitting this up in favor of faster progress to 1.0.
The user facing API can probably be slightly improved using implicits
inside of BasicBuild, but we can do that later.
Diffstat (limited to 'stage2/SbtDependencyDsl.scala')
-rw-r--r-- | stage2/SbtDependencyDsl.scala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/stage2/SbtDependencyDsl.scala b/stage2/SbtDependencyDsl.scala new file mode 100644 index 0000000..4fd4250 --- /dev/null +++ b/stage2/SbtDependencyDsl.scala @@ -0,0 +1,43 @@ +package cbt +trait SbtDependencyDsl{ self: Build => + /** 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( + MavenDependency(groupId, artifactId, version) + ) + } + implicit class DependencyBuilder(groupId: String){ + def %%(artifactId: String) = new DependencyBuilder2( groupId, artifactId, Some(scalaMajorVersion) ) + def %(artifactId: String) = new DependencyBuilder2( groupId, artifactId, None ) + } + implicit class DependencyBuilder3(d: MavenDependency){ + def %(classifier: String) = d.copy(classifier = Classifier(Some(classifier))) + } + + /* + /** SBT-like dependency builder DSL for syntax compatibility */ + implicit class DependencyBuilder0(repository: Maven){ + def %(groupId: String) = new DependencyBuilder1b(repository, groupId) + } + implicit class DependencyBuilder1a(groupId: String){ + def %%(artifactId: String) = new DependencyBuilder2( Maven.central, groupId, artifactId, Some(scalaMajorVersion) ) + def %(artifactId: String) = new DependencyBuilder2( Maven.central, groupId, artifactId, None ) + } + class DependencyBuilder1b(repository: Maven, groupId: String){ + def %%(artifactId: String) = new DependencyBuilder2( repository, groupId, artifactId, Some(scalaMajorVersion) ) + def %(artifactId: String) = new DependencyBuilder2( repository, groupId, artifactId, None ) + } + class DependencyBuilder2( repository: Maven, groupId: String, artifactId: String, scalaMajorVersion: Option[String] ){ + def %(version: String) = scalaMajorVersion.map( + v => repository(groupId, artifactId, version, scalaMajorVersion = v) + ).getOrElse( + repository.java(groupId, artifactId, version) + ) + } + implicit class DependencyBuilder3(d: MavenDependency){ + def %(classifier: String) = d.copy(classifier = Classifier(Some(classifier))) + } + */ +}
\ No newline at end of file |