Cameron Stokes's Blog

Using Gradle to Build CoffeeScript

Here’s a simple Gradle script for building and cleaning CoffeeScript with two tasks: coffee and clean.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import org.gradle.plugins.javascript.coffeescript.CoffeeScriptCompile

apply plugin: 'coffeescript-base'

repositories {
  mavenCentral()
  mavenRepo name: "Gradle", url: "http://repo.gradle.org/gradle/repo"
}

def sourceDir = "src/main/coffeescript"
def buildDir = "src/main/webapp/compiled"

task clean( type: Delete, overwrite: true ) {
  delete buildDir
}

task coffee( type: CoffeeScriptCompile ) {
  source fileTree( sourceDir )
  destinationDir file( buildDir )
}

Tech

Comments