Exploring How To Write Custom Gradle Tasks @WorldOfZeroDevelopment
Exploring How To Write Custom Gradle Tasks  @WorldOfZeroDevelopment
Uploaded August 2019 | Updated November 2026, 2 hours ago
Gradle is a build tool for Java and other JDK based projects that uses a series of tasks to compile, test and run your projects. One of the advantages of Gradle being based upon tasks instead of specific features is that it is very extensible. This means different tools can add more features to the project as needed (for example a linter can create a `gradle lint` task). It also means *we* can add more features to our projects by creating our own custom tasks.

In this video we're going to explore the basics of creating a new gradle project with `gradle init` and then adding a new custom task that can print information to our terminal or run a custom command line tool.

To register a basic task named `hello` in Gradle you could use. This task will print out a cool cat:

```groovy
tasks.register('hello') {
def kitty = """ /\\____/\\ __
.' \"\"\"\" `,-' `--.__
__,- : - - ; " :: `-. -.__
,-sssss `._ `' _,'" ,'~~~::`.sssss-.
|ssssss ,' ,_`--'_ __,' :: ` `.ssssss|
|sssssss `-._____~ `,,'_______,---_;; ssssss|
|ssssssssss `--'~{__ ____ ,'ssssss|
`-ssssssssssssssssss ~~~~~~~~~~~~ ssss.-'
`---.sssssssssssssssssssss.---'"""
println kitty
}
```

To run this task you would run `gradle hello` in the same directory as the build.gradle file you added this to.

If you want to learn how to install Gradle, learn more here: docs.gradle.org/current/userguide/installation.html

Gradle's docs are available on their website: guides.gradle.org/writing-gradle-tasks

More documentation and example use cases of the Gradle `exec` API: docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html

Join the World of Zero Discord Server: discord.gg/hU5Kq2u
Exploring How To Write Custom Gradle TasksA Circle Shader in Shader Graph - Ripple in Shader Graph - Part 1Making Our Pixels Round -  Circle Pixel Shader - Part 3Shooting Through Walls With Bullet Penetration in UnityDraw Debug Information in the Unity Editor with Gizmos - Quick TipBuilding a Game Board in UnityBuilding a Browser Based Game with Babylon.JSExperimenting with Obstacle Avoidance in Unity 3DUsing Dependency Injection in ASP.NETExperimenting With Top Down Spaceship Movement ControllersTracking Task Progress in UnityNavigate Your Shell With pushd and popd - Quick Tip
World of Zero |

Exploring How To Write Custom Gradle Tasks

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER