From ac280e5fe77933397b8fd89f9ae2d8089eec5425 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 16 Mar 2011 20:09:59 -0400 Subject: [PATCH] if sbtPlugin is true, sbt dependency and resolver are added --- main/Defaults.scala | 32 ++++++++++++++++---------------- main/Keys.scala | 5 ++++- sbt/package.scala | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/main/Defaults.scala b/main/Defaults.scala index 3cd57756d..e353e1889 100755 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -451,7 +451,10 @@ object Classpaths normalizedName <<= name(StringUtilities.normalize), organization :== normalizedName, classpathFilter in GlobalScope :== "*.jar", - fullResolvers <<= (projectResolver,resolvers).map( (pr,rs) => pr +: Resolver.withDefaultResolvers(rs)), + fullResolvers <<= (projectResolver,resolvers,sbtPlugin,sbtResolver) map { (pr,rs,isPlugin,sr) => + val base = pr +: Resolver.withDefaultResolvers(rs) + if(isPlugin) sr +: base else base + }, offline in GlobalScope :== false, moduleID :== normalizedName, defaultConfiguration in GlobalScope :== Some(Configurations.Compile), @@ -461,7 +464,10 @@ object Classpaths projectResolver <<= projectResolverTask, projectDependencies <<= projectDependenciesTask, libraryDependencies in GlobalScope :== Nil, - allDependencies <<= concat(projectDependencies,libraryDependencies), + allDependencies <<= (projectDependencies,libraryDependencies,sbtPlugin,sbtDependency) map { (projDeps, libDeps, isPlugin, sbtDep) => + val base = projDeps ++ libDeps + if(isPlugin) sbtDep +: base else base + }, ivyLoggingLevel in GlobalScope :== UpdateLogging.Quiet, ivyXML in GlobalScope :== NodeSeq.Empty, ivyValidate in GlobalScope :== false, @@ -498,10 +504,13 @@ object Classpaths }, transitiveClassifiers :== Seq("sources", "javadoc"), updateClassifiers <<= (ivySbt, projectID, update, transitiveClassifiers, updateConfiguration, ivyScala) map IvyActions.transitive, - updateSbtClassifiers <<= (ivySbt, projectID, transitiveClassifiers, updateConfiguration, appConfiguration, ivyScala) map { (is, pid, classifiers, c, app, ivyScala) => + updateSbtClassifiers <<= (ivySbt, projectID, transitiveClassifiers, updateConfiguration, sbtDependency, ivyScala) map { (is, pid, classifiers, c, sbtDep, ivyScala) => + IvyActions.transitiveScratch(is, pid, "sbt", sbtDep :: Nil, classifiers, c, ivyScala) + }, + sbtResolver in GlobalScope :== dbResolver, + sbtDependency in GlobalScope <<= appConfiguration { app => val id = app.provider.id - val module = ModuleID(id.groupID, id.name, id.version, crossVersion = id.crossVersioned) - IvyActions.transitiveScratch(is, pid, "sbt", module :: Nil, classifiers, c, ivyScala) + ModuleID(id.groupID, id.name, id.version, crossVersion = id.crossVersioned) } ) @@ -688,15 +697,6 @@ object Classpaths def allJars(cr: ConfigurationReport): Seq[File] = cr.modules.values.toSeq.flatMap(mr => allJars(mr.artifacts)) def allJars(as: Iterable[(Artifact,File)]): Iterable[File] = as collect { case (a, f) if isJar(a) => f } def isJar(a: Artifact): Boolean = a.`type` == "jar" -} -trait Defaults -{ - def addSbtDependency: Setting[Seq[ModuleID]] = - libraryDependencies <<= (libraryDependencies, appConfiguration) { (libs, app) => - val id = app.provider.id - libs :+ ModuleID(id.groupID, id.name, id.version, crossVersion = true) - } - def addSbtRepository: Setting[Seq[Resolver]] = - resolvers += Resolver.url("sbt-db", new URL("http://databinder.net/repo/"))(Resolver.ivyStylePatterns) -} \ No newline at end of file + lazy val dbResolver = Resolver.url("sbt-db", new URL("http://databinder.net/repo/"))(Resolver.ivyStylePatterns) +} diff --git a/main/Keys.scala b/main/Keys.scala index 399039e03..7738bce92 100644 --- a/main/Keys.scala +++ b/main/Keys.scala @@ -195,7 +195,10 @@ object Keys val autoUpdate = SettingKey[Boolean]("auto-update") val retrieveManaged = SettingKey[Boolean]("retrieve-managed") val managedDirectory = SettingKey[File]("managed-directory") - + + val sbtResolver = SettingKey[Resolver]("sbt-resolver") + val sbtDependency = SettingKey[ModuleID]("sbt-dependency") + // special val settings = TaskKey[Settings[Scope]]("settings") } \ No newline at end of file diff --git a/sbt/package.scala b/sbt/package.scala index 3bdf57267..d5cdbc1c3 100644 --- a/sbt/package.scala +++ b/sbt/package.scala @@ -1,7 +1,7 @@ /* sbt -- Simple Build Tool * Copyright 2010 Mark Harrah */ -package object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtra with sbt.impl.DependencyBuilders with sbt.PathExtra with sbt.ProjectConstructors with sbt.Defaults +package object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtra with sbt.impl.DependencyBuilders with sbt.PathExtra with sbt.ProjectConstructors { type Setting[T] = Project.Setting[T] type ScopedKey[T] = Project.ScopedKey[T]