blob: bdeacc78ad5e42dad4e51f7e62727e64efad93ec (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package cbt_build.cbt_examples.multi_combined_example
import cbt._
trait ScalaVersion extends BaseBuild{
override def defaultScalaVersion = "2.10.6"
}
trait SharedBuild extends ScalaVersion{
override def dependencies: Seq[Dependency] = Seq( new SharedDependency(context) )
// Type-safe embedding of other build. Requires dependency in build/build/build.scala
def sub4 = new cbt_build.cbt_examples.multi_combined_example.sub4.Build(
// currently you'll have to provide the correct working directory for that build here
context.copy( workingDirectory = projectDirectory / "sub4" )
)
def sub6 = DirectoryDependency(context.workingDirectory / "sub6")
}
class SharedDependency(val context: Context) extends ScalaVersion{
override def projectDirectory = context.workingDirectory / "shared"
}
class Sub1(val context: Context) extends SharedBuild{
override def projectDirectory = context.workingDirectory / "sub1"
}
class Sub2(val context: Context) extends SharedBuild{
override def projectDirectory = context.workingDirectory / "sub2"
override def dependencies = super.dependencies ++ Seq( sub6 )
}
class Sub3(val context: Context) extends SharedBuild{
override def projectDirectory = context.workingDirectory / "sub3"
override def dependencies = Seq(
// Embed another sub build reflectively. Convenient for simple dependencies
DirectoryDependency(context.workingDirectory / "sub4", "sub41", "sub42")
)
}
class Sub5(val context: Context) extends SharedBuild{
override def projectDirectory = context.workingDirectory / "sub5"
override def dependencies = Seq( sub4.sub41.sub42 )
}
class Build(val context: Context) extends SharedBuild{
/*
Currently each sub build nested into the main build needs to be an instance
of a top-level class taking a Context as the sole parameter, similar to the
Build class itself. This restriction may be lifted for more flexibility at
some point, see https://github.com/cvogt/cbt/issues/306
*/
def sub1 = new Sub1(context)
def sub2 = new Sub2(context)
def sub3 = new Sub3(context)
def sub5 = new Sub3(context)
def helloFromSub42 = sub4.sub41.sub42.hello
/*
// DON'T DO THIS, anonymous classes are currently not supported here.
def sub3 =
new SharedCbtBuild{
def context = Build.this.context.copy(
workingDirectory = Build.this.projectDirectory ++ "/sub3"
)
}
*/
override def dependencies = Seq( sub1, sub2 ) // assembles all projects
}
|