Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple-build-tool plugin for compiling CoffeeScript files using JCoffeeScript

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 project
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.markdown
Octocat-spinner-32 TODO.org
README.markdown

coffee-script-sbt-plugin

This is a simple-build-tool plugin for compiling CoffeeScript files into their javascript conterparts. It uses the excellent JCoffeeScript.

Usage

Run thecompile-coffee-script task to compile all your CoffeeScript files under src/main/cofffee-script/ into JavaScript. For web projects the files are compiled to under src/main/webapp/javascript, for other projects they will compiled to src/main/generated-javascript/. The file structure under the source directory will be maintained.

The source and output paths can be configured via coffeeScriptDirectoryPathFinder and coffeeScriptCompiledOuputDirectory properties. i.e.

class Project(info: ProjectInfo) extends DefaultProject(info) {
  override def coffeeScriptDirectoryPathFinder = "src" / "main" / "custom-coffee-script"
  override def coffeeScriptCompiledOuputDirectory = "src/main/custom-generated-javascript"
...
}

See sbt's documentation on Paths for more information on the coffeeScriptDirectoryPathFinder property.

CoffeeScript files are also added the watchPaths so that triggered actions will also be invoked when any CoffeeScript file changes.

Setup

  1. In your plugin definition file, add a dependency on coffee-script-sbt-plugin

    i.e. in project/plugins/Plugins.scala

    import sbt._
    
    class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
      val coffeeScriptSbtRepo = "coffeeScript sbt repo" at "http://repo.coderlukes.com"
      val coffeeScript = "org.coffeescript" % "coffee-script-sbt-plugin" % "0.1.0"
    }
    
  2. In your project file, mixin the CoffeeScriptCompile trait

    i.e., in project/build/Project.scala

     import sbt._
     import org.coffeescript.CoffeeScriptCompile
    
    class YourProject(info: ProjectInfo) extends DefaultProject(info) with CoffeeScriptCompile {
       // ....
     }
    
  3. Optionally change the compile action to also include coffee-script-compile

    override def compileAction = super.compileAction dependsOn(compileCoffeeScript)

Roadmap

See TODO.org for more information.

LICENSE

Copyright (c) 2010 Luke Amdor

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.