aboutsummaryrefslogtreecommitdiff
path: root/stage2
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-02-18 01:21:36 +0000
committerChristopher Vogt <oss.nsp@cvogt.org>2017-02-18 01:21:36 +0000
commitc9d6afb6f139e7dd4dbe3b1e474f4383570b5ff7 (patch)
tree85928ef0176ddb7901f0b4c7ca3779b96e26ed27 /stage2
parent3c135b40c2d2aac017ac12edc6924e3c369296fd (diff)
downloadcbt-c9d6afb6f139e7dd4dbe3b1e474f4383570b5ff7.tar.gz
cbt-c9d6afb6f139e7dd4dbe3b1e474f4383570b5ff7.tar.bz2
cbt-c9d6afb6f139e7dd4dbe3b1e474f4383570b5ff7.zip
support DirectoryDependency on sub builds of a multi project builds
Diffstat (limited to 'stage2')
-rw-r--r--stage2/BasicBuild.scala7
-rw-r--r--stage2/BuildDependency.scala31
2 files changed, 30 insertions, 8 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index c1a8c4e..5c49395 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -106,8 +106,9 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
scalaVersion: String = scalaMajorVersion
) = lib.ScalaDependency( groupId, artifactId, version, classifier, scalaVersion )
- final def DirectoryDependency(path: File) = cbt.DirectoryDependency(
- context.copy( workingDirectory = path, args = Seq() )
+ final def DirectoryDependency(path: File, pathToNestedBuild: String*) = cbt.DirectoryDependency(
+ context.copy( workingDirectory = path ),
+ pathToNestedBuild: _*
)
def triggerLoopFiles: Seq[File] = sources ++ transitiveDependencies.collect{ case b: TriggerLoop => b.triggerLoopFiles }.flatten
@@ -187,7 +188,7 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge
def test: Any =
lib.callReflective(
- DirectoryDependency(projectDirectory++"/test").build,
+ DirectoryDependency(projectDirectory++"/test").dependency,
Some("run")
)
diff --git a/stage2/BuildDependency.scala b/stage2/BuildDependency.scala
index 56069c3..0162791 100644
--- a/stage2/BuildDependency.scala
+++ b/stage2/BuildDependency.scala
@@ -15,7 +15,7 @@ trait TriggerLoop extends DependencyImplementation{
def triggerLoopFiles: Seq[File]
}
/** You likely want to use the factory method in the BasicBuild class instead of this. */
-final case class DirectoryDependency(context: Context) extends TriggerLoop{
+final case class DirectoryDependency(context: Context, pathToNestedBuild: String*) extends TriggerLoop{
def classLoaderCache = context.classLoaderCache
override def toString = show
override def show = this.getClass.getSimpleName ++ "(" ++ context.workingDirectory.string ++ ")"
@@ -23,12 +23,33 @@ final case class DirectoryDependency(context: Context) extends TriggerLoop{
lazy val logger = context.logger
override lazy val lib: Lib = new Lib(logger)
def transientCache = context.transientCache
- private lazy val root = lib.loadRoot( context.copy(args=Seq()) )
- lazy val build = root.finalBuild
+ private lazy val root = lib.loadRoot( context )
+ lazy val dependency: Dependency = {
+ def selectNestedBuild( build: Dependency, names: Seq[String], previous: Seq[String] ): Dependency = {
+ names.headOption.map{ name =>
+ if( lib.taskNames(build.getClass).contains(name) ){
+ val method = build.getClass.getMethod(name)
+ val returnType = method.getReturnType
+ if( classOf[Dependency] isAssignableFrom returnType ){
+ selectNestedBuild(
+ method.invoke(build).asInstanceOf[Dependency],
+ names.tail,
+ previous :+ name
+ )
+ } else {
+ throw new RuntimeException( s"Expected subtype of Dependency, found $returnType for " + previous.mkString(".") + " in " + show )
+ }
+ } else {
+ throw new RuntimeException( (previous :+ name).mkString(".") + " not found in " + show )
+ }
+ }.getOrElse( build )
+ }
+ selectNestedBuild( root.finalBuild(context.workingDirectory), pathToNestedBuild, Nil )
+ }
def exportedClasspath = ClassPath()
- def dependencies = Seq(build)
+ def dependencies = Seq(dependency)
def triggerLoopFiles = root.triggerLoopFiles
- def lastModified = build.lastModified
+ def lastModified = dependency.lastModified
def targetClasspath = ClassPath()
}
/*