Adjust to 1.0.x

This commit is contained in:
Eugene Yokota 2017-01-15 00:53:05 -05:00
parent b4a1f66aea
commit d91df1f189
9 changed files with 19 additions and 40 deletions

View File

@ -196,7 +196,7 @@ lazy val commandProj = (project in file("main-command")).
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats
).
configure(addSbtCompilerInterface, addSbtIO, addSbtUtilLogging, addSbtUtilCompletion, addSbtCompilerClasspath)
configure(addSbtCompilerInterface, addSbtIO, addSbtUtilLogging, addSbtUtilCompletion, addSbtCompilerClasspath, addSbtLm)
// Fixes scope=Scope for Setting (core defined in collectionProj) to define the settings system used in build definitions
lazy val mainSettingsProj = (project in file("main-settings")).

View File

@ -82,31 +82,6 @@ object BasicCommands {
state
}
def templateCommand = Command.make(TemplateCommand, templateBrief, templateDetailed)(templateCommandParser)
def templateCommandParser(state: State) =
{
val p = (token(Space) ~> repsep(StringBasic, token(Space))) | (token(EOF) map { case _ => Nil })
val trs = (state get templateResolvers) match {
case Some(trs) => trs.toList
case None => Nil
}
applyEffect(p)({ inputArg =>
val arguments = inputArg.toList ++
(state.remainingCommands.toList match {
case "shell" :: Nil => Nil
case xs => xs
})
trs find { tr =>
tr.isDefined(arguments.toArray)
} match {
case Some(tr) => tr.run(arguments.toArray)
case None =>
System.err.println("Template not found for: " + arguments.mkString(" "))
}
"exit" :: state.copy(remainingCommands = Nil)
})
}
def multiParser(s: State): Parser[List[String]] =
{
val nonSemi = token(charClass(_ != ';').+, hide = const(true))

View File

@ -3,7 +3,7 @@ package sbt
import java.io.File
import sbt.internal.util.AttributeKey
import sbt.internal.inc.classpath.ClassLoaderCache
import sbt.template.TemplateResolver
import sbt.librarymanagement.ModuleID
object BasicKeys {
val historyPath = AttributeKey[Option[File]]("history", "The location where command line history is persisted.", 40)
@ -16,3 +16,5 @@ object BasicKeys {
private[sbt] val explicitGlobalLogLevels = AttributeKey[Boolean]("explicit-global-log-levels", "True if the global logging levels were explicitly set by the user.", 10)
private[sbt] val templateResolverInfos = AttributeKey[Seq[TemplateResolverInfo]]("templateResolverInfos", "List of template resolver infos.", 1000)
}
case class TemplateResolverInfo(module: ModuleID, implementationClass: String)

View File

@ -279,5 +279,3 @@ object State {
private[sbt] def getBoolean(s: State, key: AttributeKey[Boolean], default: Boolean): Boolean =
s.get(key) getOrElse default
}
case class TemplateResolverInfo(module: ModuleID, implementationClass: String)

View File

@ -27,7 +27,6 @@ import org.apache.ivy.core.module.{ descriptor, id }
import descriptor.ModuleDescriptor, id.ModuleRevisionId
import testing.Framework
import KeyRanks._
import sbt.template.TemplateResolver
import sbt.internal.{ BuildStructure, LoadedBuild, PluginDiscovery, BuildDependencies, SessionSettings, LogManager }
import sbt.io.FileFilter

View File

@ -6,7 +6,7 @@ package sbt
import java.io.File
import java.net.URI
import java.util.Locale
import Project.{ Initialize => _, Setting => _, _ }
import Project._
import Keys.{ appConfiguration, stateBuildStructure, commands, configuration, historyPath, projectCommand, sessionSettings, shellPrompt, templateResolverInfos, serverPort, thisProject, thisProjectRef, watch }
import Scope.{ GlobalScope, ThisScope }
import Def.{ Flattened, Initialize, ScopedKey, Setting }
@ -17,7 +17,6 @@ import sbt.internal.util.complete.DefaultParsers
import sbt.librarymanagement.Configuration
import sbt.util.Eval
import sjsonnew.JsonFormat
import sbt.template.TemplateResolver
import language.experimental.macros

View File

@ -2,14 +2,19 @@ package sbt
import java.lang.reflect.InvocationTargetException
import java.io.File
import sbt.util._
import sbt.internal.util._
import xsbti.AppConfiguration
import sbt.classpath.ClasspathUtilities
import sbt.internal.inc.classpath.ClasspathUtilities
import BasicCommandStrings._
import BasicKeys._
import complete.{ Parser, DefaultParsers }
import DefaultParsers._
import Command.applyEffect
import Path._
import sbt.io._
import sbt.io.syntax._
import sbt.librarymanagement._
import sbt.internal.librarymanagement.IvyConfiguration
private[sbt] object TemplateCommandUtil {
def templateCommand = Command.make(TemplateCommand, templateBrief, templateDetailed)(templateCommandParser)
@ -28,8 +33,8 @@ private[sbt] object TemplateCommandUtil {
applyEffect(p)({ inputArg =>
val arguments = inputArg.toList ++
(state.remainingCommands.toList match {
case "shell" :: Nil => Nil
case xs => xs
case exec :: Nil if exec.commandLine == "shell" => Nil
case xs => xs map { _.commandLine }
})
run(infos, arguments, state.configuration, ivyConf, globalBase, ivyScala, log)
"exit" :: s2.copy(remainingCommands = Nil)
@ -76,7 +81,7 @@ private[sbt] object TemplateCommandUtil {
// Cache files under ~/.sbt/0.13/templates/org_name_version
private def classpathForInfo(info: TemplateResolverInfo, ivyConf: IvyConfiguration, globalBase: File, ivyScala: Option[IvyScala], log: Logger): List[File] =
{
val updateUtil = new UpdateUtil(ivyConf, log)
val lm = new DefaultLibraryManagement(ivyConf, log)
val templatesBaseDirectory = new File(globalBase, "templates")
val templateId = s"${info.module.organization}_${info.module.name}_${info.module.revision}"
val templateDirectory = new File(templatesBaseDirectory, templateId)
@ -84,8 +89,8 @@ private[sbt] object TemplateCommandUtil {
if (!(info.module.revision endsWith "-SNAPSHOT") && jars.nonEmpty) jars.toList
else {
IO.createDirectory(templateDirectory)
val m = updateUtil.getModule(info.module.copy(configurations = Some("component")), ivyScala)
val xs = updateUtil.update(m, templateDirectory)(_ => true).toList.flatten
val m = lm.getModule(info.module.withConfigurations(Some("component")), ivyScala)
val xs = lm.update(m, templateDirectory)(_ => true).toList.flatten
xs
}
}

View File

@ -3,6 +3,7 @@ package plugins
import Def.Setting
import Keys._
import librarymanagement._
/**
* An experimental plugin that adds the ability for Giter8 templates to be resolved

View File

@ -13,7 +13,7 @@ object Dependencies {
// sbt modules
private val ioVersion = "1.0.0-M9"
private val utilVersion = "1.0.0-M18"
private val lmVersion = "1.0.0-X4"
private val lmVersion = "1.0.0-X5"
private val zincVersion = "1.0.0-X8"
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion