intro to gradle
Most of my experience so far with JVM build systems has been with SBT. I recently started gaining exposure to Gradle and so far, I am a fan. Here’s a few items I learned today
On Mac, brew install gradle
- Gradle plugins add their own tasks to a project
- Therefore
gradle tasks
is a useful command on any project
General Info
-
project
is the top level object. -
project.task(“Hello”) == task(“Hello”) == task “Hello” == task Hello
-
def projectVersion = "2.1.0"
scopes a variable to the build file -
mustRunAfter
andshouldRunAfter
ONLY kick in when tasks are triggered from the command line. In other words, it is not a way to specify a task order in the build file (that is done thrudependsOn
)
Gradle provides many pre-baked tasks types which can be used in a project by specifying the type of a user-defined task. For example: task RunMyTests(type: Test)
. Other examples:
Task Lifecycle
- Initialization
- Configuration - executes non-action parts of the task (i.e.
description
) - Execute -
doFirst
,doLast