Engineering Full Stack Apps with Java and JavaScript
Gradle is an open source build automation tool, and is licensed under the ASL. Gradle is designed for large multi-project builds. Gradle builds upon the concepts of Ant and Maven, and introduced a Groovy-based domain-specific language (DSL) instead of traditional XML form for configurations. We quickly looked into the other popular build tools previously.
Gradle supports incremental builds and intelligently determine not to re-execute up-to-date parts of the build tree and dependencies. Though Gradle provides out of the box conventions, it also provides means of developing our own build standards.
Gradle uses a directed acyclic graph ("DAG") to determine the order in which tasks can be run. Maven does this by defining lifecycles and Ant targets are invoked based upon a depends-on partial ordering. Migrating builds from Ant, Ivy or Maven to Gradle can be done easily in stages. Gradle can interface with Maven and Ivy repositories, and can call existing Ant build files. Gradle also provides a converter for turning a Maven pom.xml into a Gradle script.
According to Gradle overview @ gradle.org, they decided to choose a build script based on Groovy dynamic scripting language than XML, to be closer to the Java developers who will be actually using it. However they did not use Java as they required more capabilities than java provides for build activities.
Groovy is an agile and dynamic language for the Java Virtual Machine inspired by languages like Python, Ruby etc. with very less learning curve for Java developers. Groovy uses a Java-like curly-bracket syntax. Most Java code is also syntactically valid Groovy. Though you won’t require any Groovy knowledge for simple build scripts, knowledge of Groovy can be handy for working with bigger and complex build files.
This approach also exposes the raw scripting power of a dynamic language to build scripts to do general purpose programming tasks and control flows. Moreover XML based build files become difficult to maintain and understand when they grow large.
Since Gradle build files are groovy scripts, you can always use raw groovy scripting. But the preferred approach for gradle is to use the domain specific language (DSL) provided by gradle. A domain-specific language (DSL) is a computer language specialized to a particular application domain, in contrast to a general-purpose language, which is broadly applicable across domains. Gradle’s DSL is easy to learn even without any groovy knowledge. DSL has idioms specific to the build tasks and gradle suggests to use these idioms wherever possible first before actually scripting using raw groovy.
If something is missing or is not as required, you can also extend DSL through plugins by adding or even modifying tasks. So there is very little need for you to do raw groovy scripting. Also, note that the concept of plugin here is not same as that of maven plugins.
We will see how to use gradle next. You can refer to a more detailed gradle overview @ http://www.gradle.org/overview or any of the references below.
http://www.gradle.org/overview
http://www.gradle.org/downloads
http://en.wikipedia.org/wiki/Gradle
http://en.wikipedia.org/wiki/Groovy_%28programming_language%29
http://en.wikipedia.org/wiki/Domain-specific_language
Book: Building and Testing with Gradle by Tim Berglund and Matthew McCullough.