Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run sbt new with a local template (not GitHub)?

Tags:

scala

sbt

giter8

I work in a secure environment where developers are not allowed to git-clone from GitHub, or any other external repos.

I was able to download a g8 template (play-scala-seed) from GitHub as a zip file and I've unzipped it to a local folder. Can I use that local directory instead of a git repo?

My first attempt at this failed:

> dir .\play-scala-seed
 Volume in drive C is OSDisk
 Volume Serial Number is A074-A016

 Directory of C:\workspace\play-scala-seed

03/22/2018  11:03 AM    <DIR>          .
03/22/2018  11:03 AM    <DIR>          ..
03/22/2018  11:01 AM    <DIR>          project
03/22/2018  10:57 AM    <DIR>          src
03/22/2018  11:03 AM    <DIR>          target
03/22/2018  10:57 AM                70 .gitignore
03/22/2018  10:57 AM               509 .travis.yml
03/22/2018  10:57 AM               453 build.sbt
03/22/2018  10:57 AM               439 LICENSE
03/22/2018  10:57 AM             1,166 README.md
               5 File(s)          2,637 bytes
               5 Dir(s)  220,172,980,224 bytes free

Even though I'm sure the template exists and in in a directory called "play-scala-seed", it's not accepted by the SBT new command:

> sbt new .\play-scala-seed
Template not found for: .\play-scala-seed

So how can I make sbt new use a local directory for a g8 template?

I'm running Windows (if that matters!)

like image 606
Salim Fadhley Avatar asked Mar 22 '18 11:03

Salim Fadhley


1 Answers

When you use giter8 directly you just need to refer to your local template with the file:// prefix:

g8 file://play-scala-seed

As mentioned by @volia17, you can find it in the giter8 documentation: Testing templates locally.

But when you use sbt new, you need you template name (folder) to end with .g8. sbt can accept different types of templates and this way it knows that this is a giter8 template. So you can rename your template folder to play-scala-seed.g8:

sbt new file://play-scala-seed.g8

P.S. Using giter8 directly is much faster, because sbt new takes time to start (it loads global sbt plugins every time).

like image 110
laughedelic Avatar answered Sep 19 '22 09:09

laughedelic