Skip to content

Instantly share code, notes, and snippets.

@koizuss
Created September 11, 2012 06:07
Show Gist options
  • Save koizuss/3696344 to your computer and use it in GitHub Desktop.
Save koizuss/3696344 to your computer and use it in GitHub Desktop.
Compile JavaScript on Gradle
archivesBaseName = 'hoge'
version = '0.0.0-snapshot'
import com.google.javascript.jscomp.ant.CompileTask
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.javascript:closure-compiler:rr2079.1'
}
}
task clean << {
ant.delete(dir: buildDir)
}
/**
* Compile JavaScript
* @see http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/ant/CompileTask.java
*/
task compile << {
def jscomp = new CompileTask()
jscomp.output = file("${buildDir}/${name}/${archivesBaseName}-${version}.min.js")
jscomp.addSources(ant.filelist(dir: "src/main/js", files: "${archivesBaseName}.js"))
jscomp.execute()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment