Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit 9fd8ca690a816deea2b72412983ecacd725cff2a @mbknor committed Nov 22, 2011
@@ -0,0 +1,3 @@
+.idea
+.idea_modules
+target
@@ -0,0 +1,12 @@
+sbtPlugin := true
+
+name := "sbt-gte-compiler"
+
+version := "0.1.0"
+
+organization := "com_kjetland"
+
+
+libraryDependencies ++= Seq(
+ "com.novocode" % "junit-interface" % "0.7" % "test"
+)
@@ -0,0 +1,3 @@
+resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"
+
+addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "0.11.0")
@@ -0,0 +1,45 @@
+package com_kjetland
+
+class GTECompilerPlugin extends sbt.Plugin {
+ import sbt._
+ import Keys._
+
+ val newTask = TaskKey[Unit]("xxxx")
+
+ sourceGenerators in Compile <+= (sourceDirectory in Compile, sourceManaged in Compile) map lookForFilesAndCompile
+
+ def lookForFilesAndCompile(sourceDirectory: File, generatedDir: File) = {
+ System.out.println("lookForFilesAndCompile: " + sourceDirectory + " " + generatedDir);
+
+ (generatedDir ** "*.template.scalaXXXX").get.map(_.getAbsoluteFile)
+ }
+}
+
+
+object GTECompiler {
+ import java.io.File
+ /**
+ * Finds all template files under sourceDirectory, checks if it need to be regenerated, then do it
+ */
+ def findAndCompile(sourceDirectory: File, generatedDir: File) = {
+ // look for view-folder
+ val viewFolder = new File(sourceDirectory, "view");
+
+ val templateFiles = findTemplateFiles(viewFolder)
+
+ }
+
+ def findTemplateFiles( folder : File) : List[File] = {
+ val l = folder.listFiles().toList map {file : File => {
+ val f :List[File] = if ( file.isDirectory) {
+ findTemplateFiles( file )
+ } else {
+ List(file)
+ }
+ f
+ }}
+
+ l.flatten
+ }
+}
+
@@ -0,0 +1 @@
+template: 'a'
@@ -0,0 +1 @@
+template: 'b'
@@ -0,0 +1,14 @@
+package com_kjetland
+
+import org.junit.Test
+import java.io.File
+
+
+class GTECompilerTest {
+
+ @Test
+ def testFindTemplateFiles {
+ val files = GTECompiler.findTemplateFiles( new File("src/test/resources"))
+ files foreach {println(_)}
+ }
+}

0 comments on commit 9fd8ca6

Please sign in to comment.