Skip to content

Instantly share code, notes, and snippets.

@jmruc
Created September 18, 2012 07:09
Show Gist options
  • Save jmruc/3741726 to your computer and use it in GitHub Desktop.
Save jmruc/3741726 to your computer and use it in GitHub Desktop.
Download and unpack dojo using gradle
def dojoVersion = '1.8.0'
//dir to keep dojo zip and version
def dojoTempDir = 'dojo'
//where to extract dojo, there would be dirs ['dojo', 'dojox', 'dijit', 'util'] in there
def appDir = "app"
def dojoDownloadUrl = "http://download.dojotoolkit.org/release-${dojoVersion}/dojo-release-${dojoVersion}-src.zip"
def dojoZip = "${dojoTempDir}/dojo.zip"
def dojoUrlFile = "${dojoTempDir}/dojo.url"
def dojoDirs = ['dojo', 'dojox', 'dijit', 'util']
//make it run by just running 'gradle'
defaultTasks 'unpackDojo'
task setVersionFile << {
file(dojoTempDir).mkdirs()
file(dojoUrlFile).write(dojoDownloadUrl)
}
task downloadDojo(dependsOn: setVersionFile) {
inputs.file dojoUrlFile
outputs.file dojoZip
doLast {
ant.get(src: dojoDownloadUrl, dest: dojoZip)
}
}
task unpackDojo(dependsOn: downloadDojo) {
inputs.file dojoZip
dojoDirs.each {
outputs.dir "${appDir}/${it}"
}
doFirst {
file(appDir).mkdirs()
}
doLast {
println "Unzipping dojo"
ant.unzip(src : dojoZip, dest : dojoTempDir)
def unpackedDir = "${dojoTempDir}/dojo-release-${dojoVersion}-src"
dojoDirs.each {
println "Deleting dir '${appDir}/${it}'"
file("${appDir}/${it}").deleteDir()
}
println "Copying dojo to dir '${appDir}'"
copy {
from unpackedDir
into appDir
}
println "Removing temp dir"
file(unpackedDir).deleteDir();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment