From 73a427c0b89ffa019e5580c0cb8e57f991c09535 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 22 Aug 2016 02:38:46 -0400 Subject: [PATCH 1/7] Adds templateResolvers and `new` command This adds `new` command, which helps create a new build definition. The `new` command is extensible via a mechanism called the template resolver, which evaluates the arbitrary arguments passed to the command to find and run a template. As a reference implementation [Giter8][g8] is provided as follows: sbt new eed3si9n/hello.g8 This will run eed3si9n/hello.g8 using Giter8. [g8]: http://www.foundweekends.org/giter8/ --- build.sbt | 2 +- .../main/scala/sbt/BasicCommandStrings.scala | 5 +++ .../src/main/scala/sbt/BasicCommands.scala | 27 +++++++++++++++- .../src/main/scala/sbt/BasicKeys.scala | 2 ++ main/src/main/scala/sbt/Defaults.scala | 1 + .../scala/sbt/Giter8TemplateResolver.scala | 32 +++++++++++++++++++ main/src/main/scala/sbt/Keys.scala | 2 ++ main/src/main/scala/sbt/Main.scala | 2 +- main/src/main/scala/sbt/Project.scala | 12 +++++-- .../scala/sbt/internal/PluginDiscovery.scala | 3 +- .../sbt/plugins/Giter8ResolverPlugin.scala | 18 +++++++++++ notes/0.13.13/template_cmd.md | 14 ++++++++ project/Dependencies.scala | 2 ++ 13 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 main/src/main/scala/sbt/Giter8TemplateResolver.scala create mode 100644 main/src/main/scala/sbt/plugins/Giter8ResolverPlugin.scala create mode 100644 notes/0.13.13/template_cmd.md diff --git a/build.sbt b/build.sbt index b530d0b18..103ee3ded 100644 --- a/build.sbt +++ b/build.sbt @@ -192,7 +192,7 @@ lazy val commandProj = (project in file("main-command")). settings( testedBaseSettings, name := "Command", - libraryDependencies ++= Seq(launcherInterface, sjsonNewScalaJson), + libraryDependencies ++= Seq(launcherInterface, sjsonNewScalaJson, templateResolverApi, giter8), sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", contrabandFormatsForType in generateContrabands in Compile := ContrabandConfig.getFormats ). diff --git a/main-command/src/main/scala/sbt/BasicCommandStrings.scala b/main-command/src/main/scala/sbt/BasicCommandStrings.scala index d99793259..7a9e127d7 100644 --- a/main-command/src/main/scala/sbt/BasicCommandStrings.scala +++ b/main-command/src/main/scala/sbt/BasicCommandStrings.scala @@ -11,6 +11,7 @@ object BasicCommandStrings { val CompletionsCommand = "completions" val Exit = "exit" val Quit = "quit" + val TemplateCommand = "new" /** The command name to terminate the program.*/ val TerminateAction: String = Exit @@ -32,6 +33,10 @@ object BasicCommandStrings { def CompletionsDetailed = "Displays a list of completions for the given argument string (run 'completions ')." def CompletionsBrief = (CompletionsCommand, CompletionsDetailed) + def templateBrief = (TemplateCommand, "Creates a new sbt build.") + def templateDetailed = TemplateCommand + """ [--options]