aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-04-03 00:09:19 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2016-04-03 00:09:26 -0400
commit83d6e39764103bde44d5812aa873ed7537cc8c97 (patch)
tree60a070ef1511aa525cec9bf4c19034804b829679 /test
parent8eae49b7b0a39f23518680b56429314db3d977e1 (diff)
downloadcbt-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 'test')
-rw-r--r--test/simple/build/build.scala34
-rw-r--r--test/test.scala53
2 files changed, 63 insertions, 24 deletions
diff --git a/test/simple/build/build.scala b/test/simple/build/build.scala
index d3887b3..190bad9 100644
--- a/test/simple/build/build.scala
+++ b/test/simple/build/build.scala
@@ -1,14 +1,30 @@
import cbt._
import scala.collection.immutable.Seq
import java.io.File
+
class Build(context: cbt.Context) extends BasicBuild(context){
- override def dependencies = Seq(
- ScalaDependency("com.typesafe.play", "play-json", "2.4.4"),
- JavaDependency("joda-time", "joda-time", "2.9.2"),
- GitDependency("https://github.com/xdotai/diff.git", "2e275642041006ff39efde22da7742c2e9a0f63f"),
- // the below tests pom inheritance with dependencyManagement and variable substitution for pom properties
- JavaDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r"),
- // the below tests pom inheritance with variable substitution for pom xml tag contents
- JavaDependency("com.spotify", "missinglink-core", "0.1.1")
- ) ++ super.dependencies
+ override def dependencies = (
+ super.dependencies
+ ++
+ Seq(
+ GitDependency("https://github.com/xdotai/diff.git", "8b501902999fe76d49e04937c4bd6d0b9e07b4a6"),
+ MavenRepository.central.resolve(
+ ScalaDependency("com.typesafe.play", "play-json", "2.4.4"),
+ MavenDependency("joda-time", "joda-time", "2.9.2"),
+ // the below tests pom inheritance with dependencyManagement and variable substitution for pom properties
+ MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r"),
+ // the below tests pom inheritance with variable substitution for pom xml tag contents
+ MavenDependency("com.spotify", "missinglink-core", "0.1.1")
+ ),
+ MavenRepository.combine(
+ MavenRepository.central,
+ MavenRepository.bintray("tpolecat"),
+ MavenRepository.sonatypeSnapshots
+ ).resolve(
+ "org.cvogt" %% "play-json-extensions" % "0.8.0",
+ "org.tpolecat" %% "tut-core" % "0.4.2",
+ "ai.x" %% "lens" % "1.0.0-SNAPSHOT"
+ )
+ )
+ )
}
diff --git a/test/test.scala b/test/test.scala
index 811e619..2c4f391 100644
--- a/test/test.scala
+++ b/test/test.scala
@@ -1,12 +1,14 @@
import cbt._
import cbt.paths._
import scala.collection.immutable.Seq
+import java.io.File
// micro framework
object Main{
def main(_args: Array[String]): Unit = {
val args = new Stage1ArgsParser(_args.toVector)
implicit val logger: Logger = new Logger(args.enabledLoggers)
+ val lib = new Lib(logger)
var successes = 0
var failures = 0
@@ -69,19 +71,14 @@ object Main{
logger.test( "Running tests " ++ _args.toList.toString )
- usage("nothing")
- compile("nothing")
- usage("multi-build")
- compile("multi-build")
- usage("simple")
- compile("simple")
-
{
val noContext = Context(cbtHome ++ "/test/nothing", Seq(), logger, false, new ClassLoaderCache(logger))
val b = new Build(noContext){
override def dependencies = Seq(
- JavaDependency("net.incongru.watchservice","barbary-watchservice","1.0"),
- JavaDependency("net.incongru.watchservice","barbary-watchservice","1.0")
+ MavenRepository.central.resolve(
+ MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"),
+ MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0")
+ )
)
}
val cp = b.classpath
@@ -90,22 +87,48 @@ object Main{
// test that messed up artifacts crash with an assertion (which should tell the user what's up)
assertException[AssertionError](){
- JavaDependency("com.jcraft", "jsch", " 0.1.53").classpath
+ MavenRepository.central.resolveOne( MavenDependency("com.jcraft", "jsch", " 0.1.53") ).classpath
}
assertException[AssertionError](){
- JavaDependency("com.jcraft", null, "0.1.53").classpath
+ MavenRepository.central.resolveOne( MavenDependency("com.jcraft", null, "0.1.53") ).classpath
}
assertException[AssertionError](){
- JavaDependency("com.jcraft", "", " 0.1.53").classpath
+ MavenRepository.central.resolveOne( MavenDependency("com.jcraft", "", " 0.1.53") ).classpath
}
assertException[AssertionError](){
- JavaDependency("com.jcraft%", "jsch", " 0.1.53").classpath
+ MavenRepository.central.resolveOne( MavenDependency("com.jcraft%", "jsch", " 0.1.53") ).classpath
}
assertException[AssertionError](){
- JavaDependency("", "jsch", " 0.1.53").classpath
+ MavenRepository.central.resolveOne( MavenDependency("", "jsch", " 0.1.53") ).classpath
}
-
+ (
+ MavenRepository.combine(
+ MavenRepository.central, MavenRepository.bintray("tpolecat")
+ ).resolve(
+ lib.ScalaDependency("org.tpolecat","tut-core","0.4.2", scalaMajorVersion="2.11")
+ ).classpath.strings
+ ++
+ MavenRepository.sonatype.resolve(
+ MavenDependency("org.cvogt","play-json-extensions_2.11","0.8.0")
+ ).classpath.strings
+ ++
+ MavenRepository.combine(
+ MavenRepository.central, MavenRepository.sonatypeSnapshots
+ ).resolve(
+ MavenDependency("ai.x","lens_2.11","1.0.0-SNAPSHOT")
+ ).classpath.strings
+ ).foreach{
+ path => assert(new File(path).exists, path)
+ }
+
+ usage("nothing")
+ compile("nothing")
+ usage("multi-build")
+ compile("multi-build")
+ usage("simple")
+ compile("simple")
+
System.err.println(" DONE!")
System.err.println( successes.toString ++ " succeeded, "++ failures.toString ++ " failed" )
if(failures > 0) System.exit(1) else System.exit(0)