Permalink
Browse files

revert plugin project settings

  • Loading branch information...
1 parent f988c68 commit 393ec9e7e4644c8116c0d3d99d92fff68f3825a4 @xuwei-k xuwei-k committed Dec 26, 2012
Showing with 51 additions and 3 deletions.
  1. +23 −0 library/src/main/scala/g8.scala
  2. +14 −0 plugin/src/main/scala/gio.scala
  3. +14 −3 project/build.scala
View
23 library/src/main/scala/g8.scala
@@ -10,6 +10,29 @@ object G8 {
private val renderer = new StringRenderer
+ def apply(fromMapping: Seq[(File,String)], toPath: File, parameters: Map[String,String]): Seq[File] =
+ fromMapping filter { !_._1.isDirectory } flatMap { case (in, relative) =>
+ apply(in, expandPath(relative, toPath, parameters), parameters)
+ }
+
+ def apply(in: File, out: File, parameters: Map[String,String]) = {
+ try {
+ if (verbatim(in, parameters)) FileUtils.copyFile(in, out)
+ else {
+ write(out, FileUtils.readFileToString(in, "UTF-8"), parameters)
+ }
+ }
+ catch {
+ case e: Exception =>
+ println("Falling back to file copy for %s: %s" format(in.toString, e.getMessage))
+ FileUtils.copyFile(in, out)
+ }
+ allCatch opt {
+ if (in.canExecute) out.setExecutable(true)
+ }
+ Seq(out)
+ }
+
def write(out: File, template: String, parameters: Map[String, String], append: Boolean = false) {
val applied = new StringTemplate(template)
.setAttributes(parameters)
View
14 plugin/src/main/scala/gio.scala
@@ -0,0 +1,14 @@
+package giter8
+
+object GIO {
+
+ def readProps(stm: java.io.InputStream) = {
+ import scala.collection.JavaConversions._
+ val p = new java.util.Properties
+ p.load(stm)
+ stm.close()
+ (Map.empty[String, String] /: p.propertyNames) { (m, k) =>
+ m + (k.toString -> p.getProperty(k.toString))
+ }
+ }
+}
View
17 project/build.scala
@@ -14,7 +14,7 @@ object Builds extends sbt.Build {
version := g8version,
scalaVersion := "2.9.1",
libraryDependencies ++= Seq(
- "org.clapper" %% "scalasti" % "0.5.8",
+ "org.clapper" % "scalasti_2.9.1" % "0.5.8",
("jline" % "jline" % "1.0" force)
),
publishArtifact in (Compile, packageBin) := true,
@@ -45,7 +45,7 @@ object Builds extends sbt.Build {
settings = buildSettings ++ Seq(
name := "giter8",
LsKeys.skipWrite := true
- )) aggregate(app, lib, scaffold)
+ )) aggregate(app, lib, scaffold, plugin)
lazy val app = Project("app", file("app"),
settings = buildSettings ++ conscriptSettings ++ buildInfoSettings ++ Seq(
@@ -67,12 +67,23 @@ object Builds extends sbt.Build {
sbtPlugin := true
)) dependsOn (lib)
+ lazy val plugin = Project("giter8-plugin", file("plugin"),
+ settings = buildSettings ++ Seq(
+ description := "sbt plugin for testing giter8 templates",
+ sbtPlugin := true,
+ resolvers ++= Seq(
+ Resolver.url("Typesafe repository", url("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns),
+ typesafeRepo
+ ),
+ libraryDependencies <+= sbtVersion("org.scala-sbt" % "scripted-plugin" % _)
+ )) dependsOn (lib)
+
lazy val lib = Project("giter8-lib", file("library"),
settings = buildSettings ++ Seq(
description :=
"shared library for app and plugin",
libraryDependencies ++= Seq(
- "me.lessis" %% "ls" % "0.1.2-RC2",
+ "me.lessis" % "ls_2.9.1" % "0.1.2-RC2",
"commons-io" % "commons-io" % "2.4"
)
))

0 comments on commit 393ec9e

Please sign in to comment.