diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-19 19:51:38 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-20 02:56:26 -0400 |
commit | d6245c8dc5c7b2f885d538b39f685327da252863 (patch) | |
tree | 846bdd92ad022dbe5a7a45e0b9d5e75bbf7779c8 /stage2/GitDependency.scala | |
parent | ca099eba708f3618bed75a5940a5a5ae1d10b684 (diff) | |
download | cbt-d6245c8dc5c7b2f885d538b39f685327da252863.tar.gz cbt-d6245c8dc5c7b2f885d538b39f685327da252863.tar.bz2 cbt-d6245c8dc5c7b2f885d538b39f685327da252863.zip |
Unify reflectively loading builds from directories.
THis is mostly cleanup and a little bit feature.
Before it was done partially in 3 places, BuildBuild,
loadRoot and GitDependency. Now DirectoryDependencies
also support referencing sub-builds.
Also introduce scalariform for the first few files
of cbt's core code :).
Diffstat (limited to 'stage2/GitDependency.scala')
-rw-r--r-- | stage2/GitDependency.scala | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/stage2/GitDependency.scala b/stage2/GitDependency.scala index 20e1d36..8a4a441 100644 --- a/stage2/GitDependency.scala +++ b/stage2/GitDependency.scala @@ -11,25 +11,29 @@ object GitDependency{ val GitUrl = "(git@|git://|https://|file:///)([^/:]+)[/:](.+)".r def apply( url: String, ref: String, subDirectory: Option[String] = None, // example: git://github.com/cvogt/cbt.git#<some-hash> - pathToNestedBuild: Seq[String] = Seq() - )(implicit context: Context ): BuildInterface = { - def moduleKey = ( + subBuild: Option[String] = None + )(implicit context: Context ): LazyDependency = withCheckoutDirectory(url, ref, subDirectory, subBuild)._2 + def withCheckoutDirectory( + url: String, ref: String, subDirectory: Option[String] = None, // example: git://github.com/cvogt/cbt.git#<some-hash> + subBuild: Option[String] = None + )(implicit context: Context ): ( File, LazyDependency ) = { + lazy val moduleKey = ( this.getClass.getName ++ "(" ++ url ++ subDirectory.map("/" ++ _).getOrElse("") ++ "#" ++ ref ++ ", " - ++ pathToNestedBuild.mkString(", ") + ++ subBuild.mkString(", ") ++ ")" ) - val taskCache = new PerClassCache(context.transientCache, moduleKey)(context.logger) - - val c = taskCache[Dependency]("checkout").memoize{ checkout( url, ref ) } - DirectoryDependency( + val taskCache = new PerClassCache( context.transientCache, moduleKey )( context.logger ) + val c = taskCache[Dependency]("checkout").memoize{ checkout(url, ref) } + val workingDirectory = subDirectory.map(c / _).getOrElse(c) + c -> DirectoryDependency( context.copy( - workingDirectory = subDirectory.map(c / _).getOrElse(c), + workingDirectory = workingDirectory, loop = false ), - pathToNestedBuild: _* + subBuild ) } def checkout(url: String, ref: String)(implicit context: Context): File = { |