diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | build/build.scala | 2 | ||||
-rw-r--r-- | nailgun_launcher/EarlyDependencies.java | 2 | ||||
-rw-r--r-- | plugins/scalatest/build/build.scala | 8 | ||||
-rw-r--r-- | stage1/MavenRepository.scala | 15 | ||||
-rw-r--r-- | stage1/Stage1.scala | 4 | ||||
-rw-r--r-- | stage1/Stage1Lib.scala | 10 | ||||
-rw-r--r-- | stage1/cbt.scala | 7 | ||||
-rw-r--r-- | stage1/resolver.scala | 29 | ||||
-rw-r--r-- | stage2/BasicBuild.scala | 7 | ||||
-rw-r--r-- | stage2/SbtDependencyDsl.scala | 28 | ||||
-rw-r--r-- | stage2/Scaffold.scala | 67 | ||||
-rw-r--r-- | stage2/ToolsStage2.scala (renamed from stage2/AdminStage2.scala) | 10 | ||||
-rw-r--r-- | stage2/ToolsTasks.scala (renamed from stage2/AdminTasks.scala) | 28 | ||||
-rw-r--r-- | test/simple/build/build.scala | 54 | ||||
-rw-r--r-- | test/test.scala | 40 |
16 files changed, 164 insertions, 149 deletions
@@ -50,7 +50,7 @@ class Build(context: cbt.Context) extends PackageBuild(context){ override def artifactId = "play-json-extensions" override def dependencies = super.dependencies :+ - MavenResolver(context.cbtHasChanged,context.paths.mavenCache,MavenResolver.central).resolve( + resolver(mavenCentral).bind( // encouraged way to declare dependencies ScalaDependency("com.typesafe.play", "play-json", "2.4.4"), MavenDependency("joda-time", "joda-time", "2.9.2") diff --git a/build/build.scala b/build/build.scala index 0f9efe5..0f93733 100644 --- a/build/build.scala +++ b/build/build.scala @@ -6,7 +6,7 @@ import scala.collection.immutable.Seq class Build(context: Context) extends BasicBuild(context){ // FIXME: somehow consolidate this with cbt's own boot-strapping from source. override def dependencies = { - super.dependencies :+ MavenResolver(context.cbtHasChanged,context.paths.mavenCache,MavenResolver.central).resolve( + super.dependencies ++ Resolver(mavenCentral).bind( MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"), MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r"), MavenDependency("com.typesafe.zinc","zinc","0.3.9"), diff --git a/nailgun_launcher/EarlyDependencies.java b/nailgun_launcher/EarlyDependencies.java index 7a8d033..74719c3 100644 --- a/nailgun_launcher/EarlyDependencies.java +++ b/nailgun_launcher/EarlyDependencies.java @@ -1,4 +1,4 @@ -// This file was auto-generated using `cbt admin cbtEarlyDependencies` +// This file was auto-generated using `cbt tools cbtEarlyDependencies` package cbt; import java.io.*; import java.nio.file.*; diff --git a/plugins/scalatest/build/build.scala b/plugins/scalatest/build/build.scala index d36d940..1377fa8 100644 --- a/plugins/scalatest/build/build.scala +++ b/plugins/scalatest/build/build.scala @@ -4,10 +4,10 @@ import java.io.File import scala.collection.immutable.Seq class Build(context: Context) extends BasicBuild(context){ - override def dependencies = super.dependencies ++ Seq( - MavenResolver(context.cbtHasChanged,context.paths.mavenCache,MavenResolver.central).resolve( + override def dependencies = + super.dependencies ++ + Resolver( mavenCentral ).bind( ScalaDependency("org.scalatest","scalatest","2.2.4") - ), + ) :+ context.cbtDependency - ) } diff --git a/stage1/MavenRepository.scala b/stage1/MavenRepository.scala index aa31cb8..06189d1 100644 --- a/stage1/MavenRepository.scala +++ b/stage1/MavenRepository.scala @@ -3,17 +3,8 @@ import scala.collection.immutable.Seq import java.io._ import java.net._ case class MavenResolver( cbtHasChanged: Boolean, mavenCache: File, urls: URL* ){ - def resolve( dependencies: MavenDependency* )(implicit logger: Logger): BoundMavenDependencies - = new BoundMavenDependencies( cbtHasChanged, mavenCache, urls.to, dependencies.to ) - def resolveOne( dependency: MavenDependency )(implicit logger: Logger): BoundMavenDependency + def bind( dependencies: MavenDependency* )(implicit logger: Logger): Seq[BoundMavenDependency] + = dependencies.map( BoundMavenDependency(cbtHasChanged,mavenCache,_,urls.to) ).to + def bindOne( dependency: MavenDependency )(implicit logger: Logger): BoundMavenDependency = BoundMavenDependency( cbtHasChanged, mavenCache, dependency, urls.to ) } - -object MavenResolver{ - def central = new URL("https://repo1.maven.org/maven2") - def jcenter = new URL("https://jcenter.bintray.com/releases") - def bintray(owner: String) = new URL(s"https://dl.bintray.com/$owner/maven") - private val sonatypeBase = new URL("https://oss.sonatype.org/content/repositories/") - def sonatype = sonatypeBase ++ "releases" - def sonatypeSnapshots = sonatypeBase ++ "snapshots" -} diff --git a/stage1/Stage1.scala b/stage1/Stage1.scala index e501300..5b52f50 100644 --- a/stage1/Stage1.scala +++ b/stage1/Stage1.scala @@ -29,7 +29,7 @@ final case class Stage1ArgsParser(__args: Seq[String]) { val enabledLoggers = props.get("log") - val admin = _args contains "admin" + val tools = _args contains "tools" } @@ -176,7 +176,7 @@ object Stage1{ val exitCode = ( classLoader .loadClass( - if(args.admin) "cbt.AdminStage2" else "cbt.Stage2" + if(args.tools) "cbt.ToolsStage2" else "cbt.Stage2" ) .getMethod( "run", classOf[Stage2Args] ) .invoke( diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala index 7b09be2..027818c 100644 --- a/stage1/Stage1Lib.scala +++ b/stage1/Stage1Lib.scala @@ -150,8 +150,8 @@ class Stage1Lib( val logger: Logger ) extends BaseLib{ None }else{ if( needsRecompile ){ - val central = MavenResolver(cbtHasChanged, mavenCache,MavenResolver.central) - val zinc = central.resolveOne(MavenDependency("com.typesafe.zinc","zinc", zincVersion)) + def Resolver(urls: URL*) = MavenResolver(cbtHasChanged, mavenCache, urls: _*) + val zinc = Resolver(mavenCentral).bindOne(MavenDependency("com.typesafe.zinc","zinc", zincVersion)) val zincDeps = zinc.transitiveDependencies val sbtInterface = @@ -176,9 +176,9 @@ class Stage1Lib( val logger: Logger ) extends BaseLib{ .getOrElse( throw new Exception(s"cannot find compiler-interface in zinc $zincVersion dependencies: "++zincDeps.toString) ) .jar - val scalaLibrary = central.resolveOne(MavenDependency("org.scala-lang","scala-library",scalaVersion)).jar - val scalaReflect = central.resolveOne(MavenDependency("org.scala-lang","scala-reflect",scalaVersion)).jar - val scalaCompiler = central.resolveOne(MavenDependency("org.scala-lang","scala-compiler",scalaVersion)).jar + val scalaLibrary = Resolver(mavenCentral).bindOne(MavenDependency("org.scala-lang","scala-library",scalaVersion)).jar + val scalaReflect = Resolver(mavenCentral).bindOne(MavenDependency("org.scala-lang","scala-reflect",scalaVersion)).jar + val scalaCompiler = Resolver(mavenCentral).bindOne(MavenDependency("org.scala-lang","scala-compiler",scalaVersion)).jar val start = System.currentTimeMillis diff --git a/stage1/cbt.scala b/stage1/cbt.scala index 33422cc..b1c462b 100644 --- a/stage1/cbt.scala +++ b/stage1/cbt.scala @@ -6,6 +6,13 @@ import scala.collection.immutable.Seq import java.util.concurrent.ConcurrentHashMap object `package`{ + val mavenCentral = new URL("https://repo1.maven.org/maven2") + val jcenter = new URL("https://jcenter.bintray.com") + def bintray(owner: String) = new URL(s"https://dl.bintray.com/$owner/maven") // FIXME: url encode owner + private val sonatypeBase = new URL("https://oss.sonatype.org/content/repositories/") + val sonatypeReleases = sonatypeBase ++ "releases" + val sonatypeSnapshots = sonatypeBase ++ "snapshots" + private val lib = new BaseLib implicit class FileExtensionMethods( file: File ){ def ++( s: String ): File = { diff --git a/stage1/resolver.scala b/stage1/resolver.scala index d195fa4..864ab47 100644 --- a/stage1/resolver.scala +++ b/stage1/resolver.scala @@ -109,9 +109,9 @@ abstract class DependencyImplementation extends Dependency{ } // TODO: all this hard codes the scala version, needs more flexibility -class ScalaCompilerDependency(cbtHasChanged: Boolean, mavenCache: File, version: String)(implicit logger: Logger) extends BoundMavenDependency(cbtHasChanged, mavenCache, MavenDependency("org.scala-lang","scala-compiler",version, Classifier.none), Seq(MavenResolver.central)) -class ScalaLibraryDependency (cbtHasChanged: Boolean, mavenCache: File, version: String)(implicit logger: Logger) extends BoundMavenDependency(cbtHasChanged, mavenCache, MavenDependency("org.scala-lang","scala-library",version, Classifier.none), Seq(MavenResolver.central)) -class ScalaReflectDependency (cbtHasChanged: Boolean, mavenCache: File, version: String)(implicit logger: Logger) extends BoundMavenDependency(cbtHasChanged, mavenCache, MavenDependency("org.scala-lang","scala-reflect",version, Classifier.none), Seq(MavenResolver.central)) +class ScalaCompilerDependency(cbtHasChanged: Boolean, mavenCache: File, version: String)(implicit logger: Logger) extends BoundMavenDependency(cbtHasChanged, mavenCache, MavenDependency("org.scala-lang","scala-compiler",version, Classifier.none), Seq(mavenCentral)) +class ScalaLibraryDependency (cbtHasChanged: Boolean, mavenCache: File, version: String)(implicit logger: Logger) extends BoundMavenDependency(cbtHasChanged, mavenCache, MavenDependency("org.scala-lang","scala-library",version, Classifier.none), Seq(mavenCentral)) +class ScalaReflectDependency (cbtHasChanged: Boolean, mavenCache: File, version: String)(implicit logger: Logger) extends BoundMavenDependency(cbtHasChanged, mavenCache, MavenDependency("org.scala-lang","scala-reflect",version, Classifier.none), Seq(mavenCentral)) case class ScalaDependencies(cbtHasChanged: Boolean, mavenCache: File, version: String)(implicit val logger: Logger) extends DependencyImplementation{ sd => override final val needsUpdate = false @@ -146,11 +146,11 @@ case class Stage1Dependency(cbtHasChanged: Boolean, mavenCache: File, nailgunTar override def exportedClasspath = ClassPath( Seq(nailgunTarget, stage1Target) ) val compatibilityDependency = CompatibilityDependency(cbtHasChanged, compatibilityTarget) override def dependencies = Seq( - compatibilityDependency, - MavenResolver(cbtHasChanged,mavenCache,MavenResolver.central).resolve( - MavenDependency("org.scala-lang","scala-library",constants.scalaVersion), - MavenDependency("org.scala-lang.modules","scala-xml_"+constants.scalaMajorVersion,constants.scalaXmlVersion) - ) + compatibilityDependency + ) ++ + MavenResolver(cbtHasChanged,mavenCache,mavenCentral).bind( + MavenDependency("org.scala-lang","scala-library",constants.scalaVersion), + MavenDependency("org.scala-lang.modules","scala-xml_"+constants.scalaMajorVersion,constants.scalaXmlVersion) ) } case class CompatibilityDependency(cbtHasChanged: Boolean, compatibilityTarget: File)(implicit val logger: Logger) extends DependencyImplementation{ @@ -165,11 +165,11 @@ case class CbtDependency(cbtHasChanged: Boolean, mavenCache: File, nailgunTarget override def exportedClasspath = ClassPath( Seq( stage2Target ) ) val stage1Dependency = Stage1Dependency(cbtHasChanged, mavenCache, nailgunTarget, stage1Target, compatibilityTarget) override def dependencies = Seq( - stage1Dependency, - MavenResolver(cbtHasChanged, mavenCache,MavenResolver.central).resolve( - MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"), - MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r") - ) + stage1Dependency + ) ++ + MavenResolver(cbtHasChanged, mavenCache,mavenCentral).bind( + MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"), + MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r") ) } @@ -190,7 +190,7 @@ class BoundMavenDependencies( case class MavenDependency( groupId: String, artifactId: String, version: String, classifier: Classifier = Classifier.none ){ - private[cbt] def serialize = groupId ++ ":" ++ artifactId ++ ":"++ version ++ ":" ++ classifier.name.getOrElse("") + private[cbt] def serialize = groupId ++ ":" ++ artifactId ++ ":"++ version ++ classifier.name.map(":" ++ _).getOrElse("") } object MavenDependency{ private[cbt] def deserialize = (_:String).split(":") match { @@ -218,6 +218,7 @@ case class BoundMavenDependency( version != "" && version != null && !version.startsWith(" ") && !version.endsWith(" "), s"not a valid version: '$version'" ) + override def show: String = this.getClass.getSimpleName ++ "(" ++ mavenDependency.serialize ++ ")" override def needsUpdate = false diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index fb5e652..4ae4cd1 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -47,12 +47,11 @@ class BasicBuild(val context: Context) extends DependencyImplementation with Bui def copy(context: Context): BuildInterface = lib.copy(this.getClass, context).asInstanceOf[BuildInterface] def zincVersion = "0.3.9" - def dependencies: Seq[Dependency] = Seq( + def dependencies: Seq[Dependency] = // FIXME: this should probably be removed - MavenResolver(context.cbtHasChanged, context.paths.mavenCache, MavenResolver.central).resolve( + Resolver( mavenCentral ).bind( "org.scala-lang" % "scala-library" % scalaVersion ) - ) // ========== paths ========== final private val defaultSourceDirectory = projectDirectory ++ "/src" @@ -92,6 +91,8 @@ class BasicBuild(val context: Context) extends DependencyImplementation with Bui } assertSourceDirectories() + def Resolver( urls: URL* ) = MavenResolver( context.cbtHasChanged, context.paths.mavenCache, urls: _* ) + def ScalaDependency( groupId: String, artifactId: String, version: String, classifier: Classifier = Classifier.none, scalaVersion: String = scalaMajorVersion diff --git a/stage2/SbtDependencyDsl.scala b/stage2/SbtDependencyDsl.scala index d8c0786..4c95308 100644 --- a/stage2/SbtDependencyDsl.scala +++ b/stage2/SbtDependencyDsl.scala @@ -12,32 +12,4 @@ trait SbtDependencyDsl{ self: BasicBuild => def %%(artifactId: String) = new DependencyBuilder2( groupId, artifactId, Some(scalaMajorVersion) ) def %(artifactId: String) = new DependencyBuilder2( groupId, artifactId, None ) } - implicit class DependencyBuilder3(d: MavenDependency){ - def %(classifier: String): MavenDependency = d//.copy(classifier = Classifier(Some(classifier))) - } - - /* - /** SBT-like dependency builder DSL for syntax compatibility */ - implicit class DependencyBuilder0(repository: Maven){ - def %(groupId: String) = new DependencyBuilder1b(repository, groupId) - } - implicit class DependencyBuilder1a(groupId: String){ - def %%(artifactId: String) = new DependencyBuilder2( Maven.central, groupId, artifactId, Some(scalaMajorVersion) ) - def %(artifactId: String) = new DependencyBuilder2( Maven.central, groupId, artifactId, None ) - } - class DependencyBuilder1b(repository: Maven, groupId: String){ - def %%(artifactId: String) = new DependencyBuilder2( repository, groupId, artifactId, Some(scalaMajorVersion) ) - def %(artifactId: String) = new DependencyBuilder2( repository, groupId, artifactId, None ) - } - class DependencyBuilder2( repository: Maven, groupId: String, artifactId: String, scalaMajorVersion: Option[String] ){ - def %(version: String) = scalaMajorVersion.map( - v => repository(groupId, artifactId, version, scalaMajorVersion = v) - ).getOrElse( - repository.java(groupId, artifactId, version) - ) - } - implicit class DependencyBuilder3(d: MavenDependency){ - def %(classifier: String) = d.copy(classifier = Classifier(Some(classifier))) - } - */ }
\ No newline at end of file diff --git a/stage2/Scaffold.scala b/stage2/Scaffold.scala index 407fee1..a9db667 100644 --- a/stage2/Scaffold.scala +++ b/stage2/Scaffold.scala @@ -13,7 +13,19 @@ trait Scaffold{ println( GREEN ++ "Created " ++ fileName ++ RESET ) } - def scaffoldBasicBuild( + def createMain( + projectDirectory: File + ): Unit = { + createFile(projectDirectory, "Main.scala", s"""object Main{ + def main( args: Array[String] ) = { + println( Console.GREEN ++ "Hello World" ++ Console.RESET ) + } +} +""" + ) + } + + def createBasicBuild( projectDirectory: File ): Unit = { createFile(projectDirectory, "build/build.scala", s"""import cbt._ @@ -21,22 +33,32 @@ import java.net.URL import java.io.File import scala.collection.immutable.Seq -class Build(context: Context) extends BasicBuild(context){ - override def dependencies = { // don't forget super.dependencies here - super.dependencies :+ MavenResolver(context.cbtHasChanged,context.paths.mavenCache,MavenResolver.central).resolve( - MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"), - MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r"), - MavenDependency("com.typesafe.zinc","zinc","0.3.9"), - ScalaDependency("org.scala-lang.modules","scala-xml","1.0.5") +class Build( context: Context ) extends BasicBuild( context ){ + /* + override def dependencies = ( + super.dependencies // don't forget super.dependencies here + ++ + Resolver( mavenCentral ).bind( + // automatically add Scala major version to artifact id + // CBT-style Scala dependency + ScalaDependency( "com.lihaoyi", "ammonite-ops", "0.5.5" ) + // or SBT-style Scala dependency + "com.lihaoyi" %% "ammonite-ops" % "0.5.5" + + // don't mess with the artifact id + // CBT-Style Java dependency + MavenDependency( "com.lihaoyi", "ammonite-ops_2.11", "0.5.5" ) + // or SBT-style Java dependency + "com.lihaoyi" % "ammonite-ops_2.11" % "0.5.5" ) - } + ) + */ } """ ) - } - def scaffoldBuildBuild( + def createBuildBuild( projectDirectory: File ): Unit = { createFile(projectDirectory, "build/build/build.scala", s"""import cbt._ @@ -44,14 +66,29 @@ import java.net.URL import java.io.File import scala.collection.immutable.Seq -class Build(context: Context) extends BuildBuild(context){ - override def dependencies = super.dependencies ++ Seq( - // , "com.lihaoyi" %% "ammonite-ops" % "0.5.5" +class Build( context: Context ) extends BuildBuild( context ){ +/* + override def dependencies = ( + super.dependencies // don't forget super.dependencies here + ++ + Resolver( mavenCentral ).bind( + // automatically add Scala major version to artifact id + // CBT-style Scala dependency + ScalaDependency( "com.lihaoyi", "ammonite-ops", "0.5.5" ) + // or SBT-style Scala dependency + "com.lihaoyi" %% "ammonite-ops" % "0.5.5" + + // don't mess with the artifact id + // CBT-Style Java dependency + MavenDependency( "com.lihaoyi", "ammonite-ops_2.11", "0.5.5" ) + // or SBT-style Java dependency + "com.lihaoyi" % "ammonite-ops_2.11" % "0.5.5" + ) ) + */ } """ ) - } /*, diff --git a/stage2/AdminStage2.scala b/stage2/ToolsStage2.scala index f4e61d0..df615fc 100644 --- a/stage2/AdminStage2.scala +++ b/stage2/ToolsStage2.scala @@ -1,12 +1,12 @@ package cbt import java.io._ -object AdminStage2 extends Stage2Base{ +object ToolsStage2 extends Stage2Base{ def run( _args: Stage2Args ): Unit = { - val args = _args.args.dropWhile(Seq("admin","direct") contains _) + val args = _args.args.dropWhile(Seq("tools","direct") contains _) val lib = new Lib(_args.logger) - val adminTasks = new AdminTasks(lib, args, _args.cwd, _args.classLoaderCache, _args.cache, _args.cbtHome, _args.cbtHasChanged) - new lib.ReflectObject(adminTasks){ - def usage: String = "Available methods: " ++ lib.taskNames(adminTasks.getClass).mkString(" ") + val toolsTasks = new ToolsTasks(lib, args, _args.cwd, _args.classLoaderCache, _args.cache, _args.cbtHome, _args.cbtHasChanged) + new lib.ReflectObject(toolsTasks){ + def usage: String = "Available methods: " ++ lib.taskNames(toolsTasks.getClass).mkString(" ") }.callNullary(args.lift(0)) } } diff --git a/stage2/AdminTasks.scala b/stage2/ToolsTasks.scala index 56d6ddf..c39c373 100644 --- a/stage2/AdminTasks.scala +++ b/stage2/ToolsTasks.scala @@ -1,8 +1,9 @@ package cbt import scala.collection.immutable.Seq +import java.net._ import java.io.{Console=>_,_} import java.nio.file._ -class AdminTasks( +class ToolsTasks( lib: Lib, args: Seq[String], cwd: File, @@ -13,14 +14,17 @@ class AdminTasks( ){ private val paths = CbtPaths(cbtHome, cache) import paths._ - private val mavenCentral = MavenResolver(cbtHasChanged,mavenCache,MavenResolver.central) + private def Resolver( urls: URL* ) = MavenResolver(cbtHasChanged,mavenCache,urls: _*) implicit val logger: Logger = lib.logger + def createMain: Unit = lib.createMain( cwd ) + def createBasicBuild: Unit = lib.createBasicBuild( cwd ) + def createBuildBuild: Unit = lib.createBuildBuild( cwd ) def resolve = { ClassPath.flatten( args(1).split(",").toVector.map{ d => val v = d.split(":") - mavenCentral.resolveOne(MavenDependency(v(0),v(1),v(2))).classpath + Resolver(mavenCentral).bindOne(MavenDependency(v(0),v(1),v(2))).classpath } ) } @@ -28,14 +32,14 @@ class AdminTasks( args(1).split(",").toVector.map{ d => val v = d.split(":") - mavenCentral.resolveOne(MavenDependency(v(0),v(1),v(2))).dependencyTree + Resolver(mavenCentral).bindOne(MavenDependency(v(0),v(1),v(2))).dependencyTree }.mkString("\n\n") } def amm = ammonite def ammonite = { val version = args.lift(1).getOrElse(constants.scalaVersion) val scalac = new ScalaCompilerDependency( cbtHasChanged,mavenCache, version ) - val d = mavenCentral.resolveOne( + val d = Resolver(mavenCentral).bindOne( MavenDependency( "com.lihaoyi","ammonite-repl_2.11.7",args.lift(1).getOrElse("0.5.7") ) @@ -52,24 +56,22 @@ class AdminTasks( "scala.tools.nsc.MainGenericRunner", Seq("-cp", scalac.classpath.string), scalac.classLoader(classLoaderCache) ) } - def scaffoldBasicBuild: Unit = lib.scaffoldBasicBuild( cwd ) - def scaffoldBuildBuild: Unit = lib.scaffoldBuildBuild( cwd ) def cbtEarlyDependencies = { val scalaVersion = args.lift(1).getOrElse(constants.scalaVersion) val scalaMajorVersion = scalaVersion.split("\\.").take(2).mkString(".") val scalaXmlVersion = args.lift(2).getOrElse(constants.scalaXmlVersion) val zincVersion = args.lift(3).getOrElse(constants.zincVersion) val scalaDeps = Seq( - mavenCentral.resolveOne(MavenDependency("org.scala-lang","scala-reflect",scalaVersion)), - mavenCentral.resolveOne(MavenDependency("org.scala-lang","scala-compiler",scalaVersion)) + Resolver(mavenCentral).bindOne(MavenDependency("org.scala-lang","scala-reflect",scalaVersion)), + Resolver(mavenCentral).bindOne(MavenDependency("org.scala-lang","scala-compiler",scalaVersion)) ) val scalaXml = Dependencies( - mavenCentral.resolveOne(MavenDependency("org.scala-lang.modules","scala-xml_"+scalaMajorVersion,scalaXmlVersion)), - mavenCentral.resolveOne(MavenDependency("org.scala-lang","scala-library",scalaVersion)) + Resolver(mavenCentral).bindOne(MavenDependency("org.scala-lang.modules","scala-xml_"+scalaMajorVersion,scalaXmlVersion)), + Resolver(mavenCentral).bindOne(MavenDependency("org.scala-lang","scala-library",scalaVersion)) ) - val zinc = mavenCentral.resolveOne(MavenDependency("com.typesafe.zinc","zinc",zincVersion)) + val zinc = Resolver(mavenCentral).bindOne(MavenDependency("com.typesafe.zinc","zinc",zincVersion)) def valName(dep: BoundMavenDependency) = { val words = dep.artifactId.split("_").head.split("-") @@ -100,7 +102,7 @@ class AdminTasks( val assignments = codeEach(zinc) ++ codeEach(scalaXml) val files = scalaDeps ++ transitive(scalaXml) ++ transitive(zinc) //{ case (name, dep) => s"$name =\n ${tree(dep, 4)};" }.mkString("\n\n ") - val code = s"""// This file was auto-generated using `cbt admin cbtEarlyDependencies` + val code = s"""// This file was auto-generated using `cbt tools cbtEarlyDependencies` package cbt; import java.io.*; import java.nio.file.*; diff --git a/test/simple/build/build.scala b/test/simple/build/build.scala index f54c3dc..afd4f4f 100644 --- a/test/simple/build/build.scala +++ b/test/simple/build/build.scala @@ -7,32 +7,34 @@ class Build(context: cbt.Context) extends BasicBuild(context){ super.dependencies ++ Seq( - GitDependency("https://github.com/xdotai/diff.git", "698717469b8dd86e8570b86354892be9c0654caf"), - // FIXME: make the below less verbose - MavenResolver(context.cbtHasChanged,context.paths.mavenCache,MavenResolver.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"), - // the below tests pom inheritance with variable substitution being parts of strings - MavenDependency("cc.factorie","factorie_2.11","1.2") - // the dependency below uses a maven version range. Currently not supported. - // TODO: put in a proper error message for version range not supported - //MavenDependency("com.github.nikita-volkov", "sext", "0.2.4") - ), - MavenResolver( - context.cbtHasChanged, - context.paths.mavenCache, - MavenResolver.central, - MavenResolver.bintray("tpolecat"), - MavenResolver.sonatypeSnapshots - ).resolve( - "org.cvogt" %% "play-json-extensions" % "0.8.0", - "org.tpolecat" %% "tut-core" % "0.4.2", - "ai.x" %% "lens" % "1.0.0-SNAPSHOT" - ) + GitDependency("https://github.com/xdotai/diff.git", "698717469b8dd86e8570b86354892be9c0654caf") + ) ++ + // FIXME: make the below less verbose + Resolver( mavenCentral ).bind( + 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"), + // the below tests pom inheritance with variable substitution being parts of strings + MavenDependency("cc.factorie","factorie_2.11","1.2") + // the dependency below uses a maven version range. Currently not supported. + // TODO: put in a proper error message for version range not supported + //MavenDependency("com.github.nikita-volkov", "sext", "0.2.4") + // currently breaks with can't find https://repo1.maven.org/maven2/org/apache/avro/avro-mapred/1.7.7/avro-mapred-1.7.7-hadoop2.pom.sha1 + // org.apache.spark:spark-sql_2.11:1.6.1 + // currently fails, let's see if because of a bug + // io.spray:spray-http:1.3.3 + ) ++ + Resolver( + mavenCentral, + bintray("tpolecat"), + sonatypeSnapshots + ).bind( + "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 bebd143..b425cfa 100644 --- a/test/test.scala +++ b/test/test.scala @@ -2,6 +2,7 @@ import cbt._ import scala.collection.immutable.Seq import java.util.concurrent.ConcurrentHashMap import java.io.File +import java.net.URL // micro framework object Main{ @@ -76,7 +77,7 @@ object Main{ val cache = cbtHome ++ "/cache" val mavenCache = cache ++ "/maven" val cbtHasChanged = true - val mavenCentral = MavenResolver(cbtHasChanged, mavenCache, MavenResolver.central) + def Resolver(urls: URL*) = MavenResolver(cbtHasChanged, mavenCache, urls: _*) { val noContext = ContextImplementation( @@ -97,12 +98,11 @@ object Main{ ) val b = new BasicBuild(noContext){ - override def dependencies = Seq( - mavenCentral.resolve( + override def dependencies = + Resolver(mavenCentral).bind( MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0"), MavenDependency("net.incongru.watchservice","barbary-watchservice","1.0") ) - ) } val cp = b.classpath assert(cp.strings.distinct == cp.strings, "duplicates in classpath: " ++ cp.string) @@ -110,36 +110,38 @@ object Main{ // test that messed up artifacts crash with an assertion (which should tell the user what's up) assertException[AssertionError](){ - mavenCentral.resolveOne( MavenDependency("com.jcraft", "jsch", " 0.1.53") ).classpath + Resolver(mavenCentral).bindOne( MavenDependency("com.jcraft", "jsch", " 0.1.53") ).classpath } assertException[AssertionError](){ - mavenCentral.resolveOne( MavenDependency("com.jcraft", null, "0.1.53") ).classpath + Resolver(mavenCentral).bindOne( MavenDependency("com.jcraft", null, "0.1.53") ).classpath } assertException[AssertionError](){ - mavenCentral.resolveOne( MavenDependency("com.jcraft", "", " 0.1.53") ).classpath + Resolver(mavenCentral).bindOne( MavenDependency("com.jcraft", "", " 0.1.53") ).classpath } assertException[AssertionError](){ - mavenCentral.resolveOne( MavenDependency("com.jcraft%", "jsch", " 0.1.53") ).classpath + Resolver(mavenCentral).bindOne( MavenDependency("com.jcraft%", "jsch", " 0.1.53") ).classpath } assertException[AssertionError](){ - mavenCentral.resolveOne( MavenDependency("", "jsch", " 0.1.53") ).classpath + Resolver(mavenCentral).bindOne( MavenDependency("", "jsch", " 0.1.53") ).classpath } ( - MavenResolver( - cbtHasChanged, mavenCache, MavenResolver.central, MavenResolver.bintray("tpolecat") - ).resolve( - lib.ScalaDependency("org.tpolecat","tut-core","0.4.2", scalaMajorVersion="2.11") + Dependencies( + Resolver( mavenCentral, bintray("tpolecat") ).bind( + lib.ScalaDependency("org.tpolecat","tut-core","0.4.2", scalaMajorVersion="2.11") + ) ).classpath.strings ++ - MavenResolver(cbtHasChanged, mavenCache,MavenResolver.sonatype).resolve( + Dependencies( + Resolver(sonatypeReleases).bind( MavenDependency("org.cvogt","play-json-extensions_2.11","0.8.0") - ).classpath.strings + ) + ).classpath.strings ++ - MavenResolver( - cbtHasChanged, mavenCache, MavenResolver.central, MavenResolver.sonatypeSnapshots - ).resolve( - MavenDependency("ai.x","lens_2.11","1.0.0-SNAPSHOT") + Dependencies( + Resolver( mavenCentral, sonatypeSnapshots ).bind( + MavenDependency("ai.x","lens_2.11","1.0.0-SNAPSHOT") + ) ).classpath.strings ).foreach{ path => assert(new File(path).exists, path) |