Commits

Meikel Brandmeyer committed 549d433

Put output in separate directory from closure output

  • Participants
  • Parent commits 89cec56

Comments (0)

Files changed (2)

scriptoresque-base/src/main/groovy/clojuresque/ClojureScriptBasePlugin.groovy

                 target = "none"
                 pretty = false
                 delayedDestinationDir = {
+                    FileUtil.file(project.buildDir, "javascript", set.name)
+                }
+                delayedClosureDir = {
                     FileUtil.file(project.buildDir, "gclosure", set.name)
                 }
-                delayedOutputFile = {
-                    FileUtil.file(project.buildDir, "javascript", set.name)
-                }
+                outputFileName = "${set.name}.js"
                 source set.clojureScript
                 clojureScriptRoots = set.clojureScript
                 delayedClasspath = {
                 }
                 description = "Compile the ${set.name} ClojureScript source."
             }
-            set.output.dir(builtBy: task, { task.outputFile })
+            set.output.dir task
         }
     }
 

scriptoresque-base/src/main/groovy/clojuresque/tasks/ClojureScriptCompileTask.groovy

     @Delayed
     def destinationDir
 
-    @OutputFile
     @Delayed
-    def outputFile
+    def closureDir
+
+    @Delayed
+    def outputFileName
 
     @InputFiles
     @Delayed
     def clojureScriptRoots
     def jvmOptions = {}
 
+    def getOutputFile() {
+        FileUtil.file(getDestinationDir(), getOutputFileName())
+    }
+
     def getOutputFileBuildable() {
-        project.files(getOutputFile()).builtBy(this)
+        project.files(outputFile).builtBy(this)
     }
 
     @TaskAction
         }
         destDir.mkdirs()
 
+        def cDir = this.getClosureDir()
+        if (cDir == null) {
+            throw new StopExecutionException("closureDir not set!")
+        }
+        cDir.mkdirs()
+
+        if (getOutputFileName() == null) {
+            throw new StopExecutionException("outputFileName not set!")
+        }
+        outputFile.parent.mkdirs()
+
         List<String> options = [
             "-i", clojureScriptRoots.srcDirs.iterator().next().path,
-            "-d", destDir.path,
-            "-o", this.getOutputFile().path,
+            "-d", cDir.path,
+            "-o", outputFile.path,
             "-O", optimizations,
         ]