aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2016-03-08 20:11:18 -0500
committerJan Christopher Vogt <oss.nsp@cvogt.org>2016-03-08 20:11:18 -0500
commitf4ffe8c8937ebe2c14fb4456c4108362f5cd2713 (patch)
treefe2bfbf5d4844c8b136b49a470c818226114528d
parent4518812fc211fde2ad9ab63ca72772fbb11fa6bc (diff)
parent628c8a3d093598a4ee58b37902e7328c48c337b3 (diff)
downloadcbt-f4ffe8c8937ebe2c14fb4456c4108362f5cd2713.tar.gz
cbt-f4ffe8c8937ebe2c14fb4456c4108362f5cd2713.tar.bz2
cbt-f4ffe8c8937ebe2c14fb4456c4108362f5cd2713.zip
Merge pull request #69 from cvogt/chris
Chris
-rw-r--r--circle.yml8
-rw-r--r--stage1/classloader.scala4
-rw-r--r--stage1/resolver.scala9
-rw-r--r--stage2/BasicBuild.scala6
-rw-r--r--test/multi-build/build/build.scala9
-rw-r--r--test/multi-build/code.scala5
-rw-r--r--test/multi-build/sub1/code.scala4
-rw-r--r--test/multi-build/sub2/code.scala4
-rw-r--r--test/test.scala9
9 files changed, 43 insertions, 15 deletions
diff --git a/circle.yml b/circle.yml
index a8498b4..35620d8 100644
--- a/circle.yml
+++ b/circle.yml
@@ -10,7 +10,11 @@ dependencies:
- "nailgun_launcher/target"
- "stage1/target"
- "stage2/target"
-
+ override:
+ - ./cbt direct -Dlog=all
+ - ./cbt -Dlog=all
+
test:
override:
- - ./cbt test
+ - ./cbt direct test -Dlog=all
+ - ./cbt test -Dlog=all
diff --git a/stage1/classloader.scala b/stage1/classloader.scala
index 3293dd1..50e33a2 100644
--- a/stage1/classloader.scala
+++ b/stage1/classloader.scala
@@ -8,7 +8,7 @@ import scala.collection.immutable.Seq
object ClassLoaderCache{
private val cache = NailgunLauncher.classLoaderCache
- def classLoader( classpath: ClassPath, parent: ClassLoader )(implicit logger: Logger): ClassLoader
+ def get( classpath: ClassPath )(implicit logger: Logger): ClassLoader
= cache.synchronized{
val lib = new Stage1Lib(logger)
val key = classpath.strings.sorted.mkString(":")
@@ -17,7 +17,7 @@ object ClassLoaderCache{
cache.get(key)
} else {
logger.resolver("CACHE MISS: "++key)
- val cl = new cbt.URLClassLoader( classpath, parent )
+ val cl = new cbt.URLClassLoader( classpath, ClassLoader.getSystemClassLoader )
cache.put( key, cl )
cl
}
diff --git a/stage1/resolver.scala b/stage1/resolver.scala
index 9b3276b..fae5e9d 100644
--- a/stage1/resolver.scala
+++ b/stage1/resolver.scala
@@ -45,21 +45,20 @@ abstract class Dependency{
_.right.toOption.map(_.exportedClasspath)
)
)
- val mavenClassPath = ClassPath.flatten(
+ val cachedClassPath = ClassPath.flatten(
transitiveClassPath.flatMap(
_.left.toOption
).par.map(_.exportedClasspath).seq.sortBy(_.string)
)
+
if(cacheDependencyClassLoader){
new URLClassLoader(
exportedClasspath ++ buildClassPath,
- ClassLoaderCache.classLoader(
- mavenClassPath, new URLClassLoader( mavenClassPath, ClassLoader.getSystemClassLoader )
- )
+ ClassLoaderCache.get( cachedClassPath )
)
} else {
new URLClassLoader(
- exportedClasspath ++ buildClassPath ++ mavenClassPath, ClassLoader.getSystemClassLoader
+ exportedClasspath ++ buildClassPath ++ cachedClassPath, ClassLoader.getSystemClassLoader
)
}
}
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index 6da31b7..c17bce0 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -24,7 +24,7 @@ class Build(val context: Context) extends Dependency with TriggerLoop{
// ========== general stuff ==========
def enableConcurrency = false
- final def projectDirectory: File = context.cwd
+ final def projectDirectory: File = lib.realpath(context.cwd)
assert( projectDirectory.exists, "projectDirectory does not exist: " ++ projectDirectory.string )
final def usage: Unit = new lib.ReflectBuild(this).usage
/*
@@ -151,7 +151,7 @@ class Build(val context: Context) extends Dependency with TriggerLoop{
context.logger.composition(">"*80)
context.logger.composition("class " ++ this.getClass.toString)
- context.logger.composition("dir " ++ context.cwd.string)
+ context.logger.composition("dir " ++ projectDirectory.string)
context.logger.composition("sources " ++ sources.toList.mkString(" "))
context.logger.composition("target " ++ target.string)
context.logger.composition("context " ++ context.toString)
@@ -160,5 +160,5 @@ class Build(val context: Context) extends Dependency with TriggerLoop{
// ========== cbt internals ==========
private[cbt] def finalBuild = this
- override def show = this.getClass.getSimpleName ++ "(" ++ context.cwd.string ++ ")"
+ override def show = this.getClass.getSimpleName ++ "(" ++ projectDirectory.string ++ ")"
}
diff --git a/test/multi-build/build/build.scala b/test/multi-build/build/build.scala
new file mode 100644
index 0000000..5b9f874
--- /dev/null
+++ b/test/multi-build/build/build.scala
@@ -0,0 +1,9 @@
+import cbt._
+import scala.collection.immutable.Seq
+import java.io.File
+class Build(context: Context) extends BasicBuild(context){
+ override def dependencies = Seq(
+ BuildDependency(projectDirectory++"/sub1"),
+ BuildDependency(projectDirectory++"/sub2")
+ ) ++ super.dependencies
+}
diff --git a/test/multi-build/code.scala b/test/multi-build/code.scala
new file mode 100644
index 0000000..3fe85ad
--- /dev/null
+++ b/test/multi-build/code.scala
@@ -0,0 +1,5 @@
+object Main extends App{
+ println("root here")
+ println(Foo(5))
+ println(Bar("test"))
+}
diff --git a/test/multi-build/sub1/code.scala b/test/multi-build/sub1/code.scala
new file mode 100644
index 0000000..b2d5deb
--- /dev/null
+++ b/test/multi-build/sub1/code.scala
@@ -0,0 +1,4 @@
+case class Foo(i: Int)
+object Main extends App{
+ println("sub1 here")
+} \ No newline at end of file
diff --git a/test/multi-build/sub2/code.scala b/test/multi-build/sub2/code.scala
new file mode 100644
index 0000000..1ec6ebf
--- /dev/null
+++ b/test/multi-build/sub2/code.scala
@@ -0,0 +1,4 @@
+case class Bar(s: String)
+object Main extends App{
+ println("sub1 here")
+}
diff --git a/test/test.scala b/test/test.scala
index feab89f..deaa46c 100644
--- a/test/test.scala
+++ b/test/test.scala
@@ -51,8 +51,8 @@ object Main{
val res = runCbt(path, Seq())
logger.test(res.toString)
assertSuccess(res)
- assert(res.out == "", res.toString)
- assert(res.err contains usageString, res.toString)
+ assert(res.out == "", "usage " + path +" "+ res.toString)
+ assert(res.err contains usageString, "usage " + path +" "+res.toString)
}
def compile(path: String)(implicit logger: Logger) = {
val res = runCbt(path, Seq("compile"))
@@ -62,8 +62,11 @@ object Main{
logger.test( "Running tests " ++ args.toList.toString )
- usage("nothing")
+ //usage("nothing")
compile("nothing")
+ //usage("multi-build")
+ compile("multi-build")
+
{
val noContext = Context(cbtHome ++ "/test/nothing", Seq(), logger)