diff options
-rw-r--r-- | stage1/Stage1.scala | 2 | ||||
-rw-r--r-- | stage1/logger.scala | 2 | ||||
-rw-r--r-- | stage1/resolver.scala | 3 | ||||
-rw-r--r-- | stage2/GitDependency.scala | 49 | ||||
-rw-r--r-- | test/simple/Main.scala | 4 | ||||
-rw-r--r-- | test/simple/build/build.scala | 3 |
6 files changed, 60 insertions, 3 deletions
diff --git a/stage1/Stage1.scala b/stage1/Stage1.scala index 7702678..937d9b3 100644 --- a/stage1/Stage1.scala +++ b/stage1/Stage1.scala @@ -69,7 +69,7 @@ abstract class Stage1Base{ if( src.exists(newerThan(_, changeIndicator)) ) { val stage1Classpath = CbtDependency()(logger).dependencyClasspath logger.stage1("cbt.lib has changed. Recompiling with cp: " ++ stage1Classpath.string) - zinc( true, src, stage2Target, stage1Classpath )( zincVersion = "0.3.9", scalaVersion = constants.scalaVersion ) + zinc( true, src, stage2Target, stage1Classpath, Seq("-deprecation") )( zincVersion = "0.3.9", scalaVersion = constants.scalaVersion ) } logger.stage1(s"[$now] calling CbtDependency.classLoader") diff --git a/stage1/logger.scala b/stage1/logger.scala index 5e8858a..e513443 100644 --- a/stage1/logger.scala +++ b/stage1/logger.scala @@ -29,6 +29,7 @@ case class Logger(enabledLoggers: Set[String]) { final def resolver(msg: => String) = logGuarded(names.resolver, msg) final def lib(msg: => String) = logGuarded(names.lib, msg) final def test(msg: => String) = logGuarded(names.test, msg) + final def git(msg: => String) = logGuarded(names.git, msg) final def pom(msg: => String) = logGuarded(names.pom, msg) private object names{ @@ -41,6 +42,7 @@ case class Logger(enabledLoggers: Set[String]) { val lib = "lib" val test = "test" val pom = "pom" + val git = "git" } private def logGuarded(name: String, msg: => String) = { diff --git a/stage1/resolver.scala b/stage1/resolver.scala index 85eb248..1dbadcc 100644 --- a/stage1/resolver.scala +++ b/stage1/resolver.scala @@ -188,6 +188,7 @@ case class CbtDependency()(implicit val logger: Logger) extends Dependency{ override def dependencies = Seq( Stage1Dependency(), JavaDependency("net.incongru.watchservice","barbary-watchservice","1.0"), + JavaDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r"), lib.ScalaDependency( "com.lihaoyi","ammonite-ops","0.5.5", scalaVersion = constants.scalaMajorVersion ), @@ -319,7 +320,7 @@ case class JavaDependency( //println("found: "++v.text) v.text match { case Substitution(path) => Option(properties(path)) - //println("lookup "++path ++ ": "++(pomXml\path).text) + //println("lookup "++path ++ ": "++(pomXml\path).text) case value => Option(value) } } diff --git a/stage2/GitDependency.scala b/stage2/GitDependency.scala new file mode 100644 index 0000000..c3e38b6 --- /dev/null +++ b/stage2/GitDependency.scala @@ -0,0 +1,49 @@ +package cbt +import java.io._ +import java.net._ +import scala.collection.immutable.Seq +import org.eclipse.jgit.api._ +import org.eclipse.jgit.lib.Ref + +case class GitDependency( + url: String, ref: String // example: git://github.com/cvogt/cbt.git#<some-hash> +)(implicit val logger: Logger) extends Dependency{ + override def lib = new Lib(logger) + + // TODO: add support for authentication via ssh and/or https + // See http://www.codeaffine.com/2014/12/09/jgit-authentication/ + + private val GitUrl = "(git|https)://([^/]+)/(.+)".r + private val GitUrl( _, domain, path ) = url + + private object dependenciesCache extends Cache[Seq[Dependency]] + def dependencies = dependenciesCache{ + val checkoutDirectory = paths.cbtHome ++ s"/cache/git/$domain/$path/$ref" + if(checkoutDirectory.exists){ + logger.git(s"Found existing checkout of $url#$ref in $checkoutDirectory") + } else { + + logger.git(s"Cloning $url into $checkoutDirectory") + val git = + Git.cloneRepository() + .setURI(url) + .setDirectory(checkoutDirectory) + .call() + + logger.git(s"Checking out ref $ref") + git.checkout() + .setName(ref) + .call() + + } + val managedBuild = lib.loadDynamic( + Context( cwd = checkoutDirectory, args = Seq(), logger ) + ) + Seq( managedBuild ) + } + + def exportedClasspath = ClassPath(Seq()) + def exportedJars = Seq() + private[cbt] def targetClasspath = exportedClasspath + def updated: Boolean = false +} diff --git a/test/simple/Main.scala b/test/simple/Main.scala new file mode 100644 index 0000000..43542ff --- /dev/null +++ b/test/simple/Main.scala @@ -0,0 +1,4 @@ +import ai.x.diff +object Main extends App{ + println(diff.DiffShow.diff("a","b")) +} diff --git a/test/simple/build/build.scala b/test/simple/build/build.scala index 37de2e4..f3efc19 100644 --- a/test/simple/build/build.scala +++ b/test/simple/build/build.scala @@ -5,7 +5,8 @@ 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 JavaDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r") - ) ++ super.dependencies + ) ++ super.dependencies } |