You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/06/25 18:50:43 UTC
git commit: Add basic support for compiling CoffeeScript to
JavaScript as part of the tapestry-core build
Updated Branches:
refs/heads/5.4-js-rewrite 0735f31fd -> 98e5ca74d
Add basic support for compiling CoffeeScript to JavaScript as part of the tapestry-core build
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/98e5ca74
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/98e5ca74
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/98e5ca74
Branch: refs/heads/5.4-js-rewrite
Commit: 98e5ca74d0ace53d753b84713b1fe6e101403710
Parents: 0735f31
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Jun 25 09:50:25 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Jun 25 09:50:25 2012 -0700
----------------------------------------------------------------------
build.gradle | 3 +-
tapestry-core/build.gradle | 7 ++++
tapestry-core/coffeescript.gradle | 54 ++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/98e5ca74/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 8d4fc9a..ec806c7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,7 +16,8 @@ project.ext.versions = [
easymock: "3.0",
servletapi: "2.5",
spock: "0.6-groovy-1.8",
- hibernate: "4.1.2.Final"
+ hibernate: "4.1.2.Final",
+ wro4j: "1.4.6"
]
// Provided so that the CI server can override the normal version number for nightly builds.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/98e5ca74/tapestry-core/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-core/build.gradle b/tapestry-core/build.gradle
index 6c6e26d..c8a9e3d 100644
--- a/tapestry-core/build.gradle
+++ b/tapestry-core/build.gradle
@@ -7,6 +7,7 @@ project.ext {
antlrOutput = "$buildDir/generated-sources/antlr"
}
+apply from: "coffeescript.gradle"
configurations {
antlr3
@@ -53,6 +54,12 @@ task generateGrammarSource(type: JavaExec) {
}
}
+task compileCoffeeScript(type: CompileCoffeeScript)
+
+processResources {
+ from compileCoffeeScript
+}
+
ideaModule.dependsOn generateGrammarSource
def generatedDir = file("$buildDir/generated-sources")
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/98e5ca74/tapestry-core/coffeescript.gradle
----------------------------------------------------------------------
diff --git a/tapestry-core/coffeescript.gradle b/tapestry-core/coffeescript.gradle
new file mode 100644
index 0000000..c67e10d
--- /dev/null
+++ b/tapestry-core/coffeescript.gradle
@@ -0,0 +1,54 @@
+import ro.isdc.wro.model.resource.*
+import ro.isdc.wro.extensions.processor.js.*
+
+buildscript {
+ repositories { mavenCentral() }
+ dependencies {
+ classpath "ro.isdc.wro4j:wro4j-extensions:${versions.wro4j}"
+ }
+}
+
+class CompileCoffeeScript extends DefaultTask {
+ def srcDir = "src/main/coffeescript"
+
+ def outputDir = "${project.buildDir}/compiled-coffeescript"
+
+ @InputDirectory
+ File getSrcDir() { project.file(srcDir) }
+
+ @OutputDirectory
+ File getOutputDir() { project.file(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 tree = project.fileTree srcDir, {
+ include '**/*.coffee'
+ }
+
+ 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)
+
+ logger.info "Compiling ${inputPath}"
+
+ outputFile.parentFile.mkdirs()
+
+ def resource = Resource.create(inputFile.absolutePath, ResourceType.JS)
+
+ new CoffeeScriptProcessor().process(resource, inputFile.newReader(), outputFile.newWriter())
+ }
+ }
+
+}
+
+project.ext.CompileCoffeeScript = CompileCoffeeScript
\ No newline at end of file