You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/07/09 01:09:42 UTC
[1/2] git commit: Compile CoffeeScript modules as with --bare (no
outer function wrapper)
Updated Branches:
refs/heads/5.4-js-rewrite 8223465a2 -> 649dd1ac9
Compile CoffeeScript modules as with --bare (no outer function wrapper)
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/649dd1ac
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/649dd1ac
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/649dd1ac
Branch: refs/heads/5.4-js-rewrite
Commit: 649dd1ac96f2524bc84e1112f69aadcfddd4b6c8
Parents: 2e5a750
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Sun Jul 8 16:09:33 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Sun Jul 8 16:09:33 2012 -0700
----------------------------------------------------------------------
54_TODO.txt | 3 -
tapestry-core/coffeescript.gradle | 86 ++++++++++++++++++--------------
2 files changed, 48 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/649dd1ac/54_TODO.txt
----------------------------------------------------------------------
diff --git a/54_TODO.txt b/54_TODO.txt
index 775821a..7c0e112 100644
--- a/54_TODO.txt
+++ b/54_TODO.txt
@@ -1,8 +1,5 @@
Ideas and TODOs:
-Compile CoffeeScript for modules with --bare (no top-level function wrapper), as module is always just
-define([..], function() { ... });
-
Replace default.css with Twitter Bootstrap + Tapestry extensions.
Include a new Java module that supports writing an exception log file on error.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/649dd1ac/tapestry-core/coffeescript.gradle
----------------------------------------------------------------------
diff --git a/tapestry-core/coffeescript.gradle b/tapestry-core/coffeescript.gradle
index 8e758c1..62fb812 100644
--- a/tapestry-core/coffeescript.gradle
+++ b/tapestry-core/coffeescript.gradle
@@ -1,61 +1,71 @@
import ro.isdc.wro.model.resource.*
import ro.isdc.wro.extensions.processor.js.*
+import ro.isdc.wro.extensions.processor.support.coffeescript.*
-buildscript {
- repositories { mavenCentral() }
- dependencies {
- classpath "ro.isdc.wro4j:wro4j-extensions:${versions.wro4j}"
- }
+buildscript {
+ repositories { mavenCentral() }
+ dependencies {
+ classpath "ro.isdc.wro4j:wro4j-extensions:${versions.wro4j}"
+ }
+}
+
+class CustomizedProcessor extends CoffeeScriptProcessor {
+
+ protected CoffeeScript newCoffeeScript() {
+ CoffeeScript engine = new CoffeeScript()
+ engine.options = ["bare"]
+ return engine
+ }
}
-class CompileCoffeeScript extends DefaultTask {
+class CompileCoffeeScript extends DefaultTask {
+
+ {
+ description = "Compiles CoffeeScript sources into JavaScript"
+ group = "build"
+ }
- {
- description = "Compiles CoffeeScript sources into JavaScript"
- group = "build"
- }
+ def srcDir = "src/main/coffeescript"
- def srcDir = "src/main/coffeescript"
+ def outputDir = "${project.buildDir}/compiled-coffeescript"
- def outputDir = "${project.buildDir}/compiled-coffeescript"
+ @InputDirectory
+ File getSrcDir() { project.file(srcDir) }
- @InputDirectory
- File getSrcDir() { project.file(srcDir) }
+ @OutputDirectory
+ File getOutputDir() { project.file(outputDir) }
- @OutputDirectory
- File getOutputDir() { project.file(outputDir) }
+ @TaskAction
+ void doCompile() {
+ logger.info "Compiling CoffeeScript sources from $srcDir into $outputDir"
- @TaskAction
- void doCompile() {
- logger.info "Compiling CoffeeScript sources from $srcDir into $outputDir"
+ def outputDirFile = getOutputDir()
+ // Recursively delete output directory if it exists
+ outputDirFile.deleteDir()
- def outputDirFile = getOutputDir()
- // Recursively delete output directory if it exists
- outputDirFile.deleteDir()
+ def tree = project.fileTree srcDir, {
+ include '**/*.coffee'
+ }
- def tree = project.fileTree srcDir, {
- include '**/*.coffee'
- }
+ def processor = new CustomizedProcessor()
- def compiler = new CoffeeScriptProcessor()
+ tree.visit { visit ->
+ if (visit.directory) return
- tree.visit { visit ->
- if (visit.directory) return
+ def inputFile = visit.file
+ def inputPath = visit.path
+ def outputPath = inputPath.replaceAll(/\.coffee$/, '.js')
+ def outputFile = new File(outputDirFile, outputPath)
- def inputFile = visit.file
- def inputPath = visit.path
- def outputPath = inputPath.replaceAll(/\.coffee$/, '.js')
- def outputFile = new File(outputDirFile, outputPath)
+ logger.info "Compiling ${inputPath}"
- logger.info "Compiling ${inputPath}"
+ outputFile.parentFile.mkdirs()
- outputFile.parentFile.mkdirs()
+ def resource = Resource.create(inputFile.absolutePath, ResourceType.JS)
- def resource = Resource.create(inputFile.absolutePath, ResourceType.JS)
-
- compiler.process(resource, inputFile.newReader(), outputFile.newWriter())
+ processor.process(resource, inputFile.newReader(), outputFile.newWriter())
+ }
}
- }
}