diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | src/main/scala/spray/boilerplate/BoilerplatePlugin.scala | 8 |
2 files changed, 9 insertions, 4 deletions
@@ -88,7 +88,8 @@ to your `build.sbt`. The templates have to be put into the `src/main/boilerplate` directory and the file name must end with `.template`. The generated files will be put into the same hierarchy as they -appear in `src/main/boilerplate` with the `.template` extension stripped off. +appear in `src/main/boilerplate` with the `.template` extension stripped off. If the stripped +filename has no extension ".scala" is added automatically. ## Known issues @@ -102,6 +103,6 @@ appear in `src/main/boilerplate` with the `.template` extension stripped off. ## License -Copyright (c) 2012-2014 Johannes Rudolph +Copyright (c) 2012-2016 Johannes Rudolph Published under the [BSD 2-Clause License](http://www.opensource.org/licenses/BSD-2-Clause). diff --git a/src/main/scala/spray/boilerplate/BoilerplatePlugin.scala b/src/main/scala/spray/boilerplate/BoilerplatePlugin.scala index 32703fd..0e63014 100644 --- a/src/main/scala/spray/boilerplate/BoilerplatePlugin.scala +++ b/src/main/scala/spray/boilerplate/BoilerplatePlugin.scala @@ -31,8 +31,12 @@ object BoilerplatePlugin extends Plugin { val files = sourceDir ** "*.template" def changeExtension(f: File): File = { - val (ext, name) = f.getName.reverse.span(_ != '.') - new File(f.getParent, name.drop(1).reverse.toString) + val (_, name) = f.getName.reverse.span(_ != '.') + val strippedName = name.drop(1).reverse.toString + val newName = + if (!strippedName.contains(".")) s"$strippedName.scala" + else strippedName + new File(f.getParent, newName) } val mapping = (files x rebase(sourceDir, targetDir)).map { |