Big News! (Aug 2018)
After what seems like the longest time, Gradle support for using kotlin to drive gradle builds is now at version 1.0. This is the best time for anyone to move to gradle. This page is an introduction to gradle, using kotlin DSL
- What is a build tool?
- Which Build Tool?
- Basic App Build
- Concepts: Plugins, Dependencies and Artifact Repositories
- SourceSets, Reflect, Testing, Local Vars
What is a build Tool?
As Building software becomes ever more complex, build tools come to the rescue. A build tool is simply software designed to automate the build process, and at the same time, keep building as simple as possible.
Think of a simple batch/command/shell file (for windows/maxOS/unix respectively). In the simplest form, it can capture a command or sequence of commands and save typing them and remembering all the parameters. Working with building programs can require just such a sequence of commands, and all build tools are simply ways of running a sequence of commands.
So why not just use a simple batch/command/shell file? You can, but for complex projects it just becomes a mess. The reason is that rather than remaining simple, as projects scale up, the logic required can become far more complex, and there are some patterns that frequently occur with the commands needs to build programs, like only do a particular step if the file has changed, which benefit from specific logic.
Which Build Tool?
Make was one of the first build tools, but makefiles became painful to use as software evolved and building needs increased, then followed ‘ant‘ which introduced a configuration language based on xml.
Maven came next, and brought integrating the build process with internet, integrating online repositories of artifacts, and keeping XML configuration..
Now we get to Gradle. The innovation of gradle was to move to a program for configuration. Being a specific ‘domain’ the goal was a DSL (domain specific language) and at the time gradle emerged Groovy was chosen for the DSL capabilities of the language. Later, the Kotlin language appeared, and became even more appealing in general with arguably even more useful DSL capabilities, and now gradle scripts can be written in Kotlin as well as Groovy.
Maven and Gradle access the same artifact repositories, and that system is becoming an industry de facto standard. Gradle at this time (Aug 2018) combines state of the art build capability with configuration in Kotlin.