-
Notifications
You must be signed in to change notification settings - Fork 928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds templateResolvers and new
command
#2705
Conversation
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/
Welcome back, g8 ;-) |
Excellent, looking forward to this! |
LGTM |
Love it! |
You can use code like https://gist.github.com/nafg/05fafb7050ed38854184b4ca64612da7 to use Activator templates. It seems the way IntelliJ (and I think also Activator itself) gets activator templates is through a very complex API that ultimately gives you a zip file containing a full-text search database (perhaps it was lucene?) which you can then use the client library for locally to search. Sounds like lightbend is really trying to be enterprise-ready... What my code does instead, is simply scrape the Activator index page for template ids. You can then download the template bundle by appending the id to It shouldn't be a big deal to write a templateResolver that takes the same shortcut. |
This adds
new
command, which helps create a new build definition. Thenew
command is extensible via a mechanism called the templateresolver, which evaluates the arbitrary arguments passed to the command to find
and run a template.
See https://github.com/sbt/template-resolver/blob/master/src/main/java/sbt/template/TemplateResolver.java
As a reference implementation, Giter8 integration is provided, which works as follows:
This will run eed3si9n/hello.g8 using Giter8.
templateResolvers
is just a key in theGlobal
scope, so you can write your own auto plugin to extend it:The credit for the idea of extensible template support goes to @corruptmemory, but I take the blame for implementation details :)
update
If you want to make your own Giter8 template, see Making your own templates. All you need is a Git repo.
If you want to extend template resolving mechanism to something other than Giter8, just extend this Java class:
and define an auto plugin that adds to
templateResolvers
. For example you might want to create Maven archetype-like template, or whatever mechanism that exists in-house.