ExtJS 5 and Gradle – Playing Together

Augmenting ExtJS with Gradle

ExtJS is pretty nice, overall, and it comes with a powerful build tool – Sencha Cmd.

Running builds with it can be tedious, because it doesn’t have any up-to-date checks – it constantly rebuilds stuff it doesn’t need. Oh, the time wasting!

As it turns out, Sencha Cmd is an Ant-based build tool. Which means we can create Gradle builds that augment it – given us support for such things as up-to-date checks.

Like this:

ant.importBuild 'build.xml'
def packages_dir = file('../packages')
clean {
doLast { delete 'bootstrap.js', 'bootstrap.css', 'bootstrap.json' }
}
refresh {
inputs.dir 'app'
inputs.file 'app.json'
packages_dir.listFiles().each() { package_dir -> inputs.dir new File(package_dir, 'src') }
outputs.file file('bootstrap.js')
outputs.file file('bootstrap.json')
}
js {
inputs.dir 'app'
packages_dir.listFiles().each() { package_dir -> inputs.dir new File(package_dir, 'src') }
outputs.file file("../build/${this.property('build.environment')}/${projectName}/app.js")
}
resources {
inputs.dir 'resources'
packages_dir.listFiles().each() { package_dir -> inputs.dir new File(package_dir, 'resources') }
outputs.file file("../build/${this.property('build.environment')}/${projectName}/resources")
}
sass {
inputs.dir 'sass'
packages_dir.listFiles().each() { package_dir -> inputs.dir new File(package_dir, 'sass') }
outputs.file file("../build/${this.property('build.environment')}/${projectName}/resources/${projectName}-all.css")
outputs.file file('bootstrap.css')
}
page {
// what are the inputs to page, I wonder?
// the outputs are the microloader.js and the index.html...
}
view raw build.gradle hosted with ❤ by GitHub
# the default Build Environment. Production is the default for Sencha Cmd.
# Use -Dbuild.environment on the command line to change, otherwise it doesn't get passed to the ant build properly
build.environment=production
# The project name. Should match what is in the app.json file
projectName=MyApp

Share and Enjoy!

Author: Robert Watkins

My name is Robert Watkins. I am a software developer and have been for over 20 years now. I currently work for people, but my opinions here are in no way endorsed by them (which is cool; their opinions aren’t endorsed by me either). My main professional interests are in Java development, using Agile methods, with a historical focus on building web based applications. I’m also a Mac-fan and love my iPhone, which I’m currently learning how to code for. I live and work in Brisbane, Australia, but I grew up in the Northern Territory, and still find Brisbane too cold (after 22 years here). I’m married, with two children and one cat. My politics are socialist in tendency, my religious affiliation is atheist (aka “none of the above”), my attitude is condescending and my moral standing is lying down.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: