Gradle Tutorial: Crash Course [Video]
Looking for a fun and entertaining comprehensive look at Gradle? Look no further than this video tutorial: learn how to use Gradle like a professional.
Join the DZone community and get the full member experience.
Join For FreeEver looked for a comprehensive tutorial for Gradle that is fun and entertaining at the same time?
In this video tutorial below, you'll learn how to use Gradle like a professional. Cover topics including using the Gradle wrapper, using Gradle together with IDEs, and Gradle basics like build.gradle
, settings.gradle
, running commands (clean build), as well as understanding multi-project Gradle builds. By the end of it, there won't be many questions left when it comes to Gradle.
What’s in the Video?
Every new Gradle project starts with the question, "Where do I get Gradle from in the first place?" Hold on a second. Almost every Gradle project out there in the wild comes with its own embedded version of Gradle called the Gradle wrapper. Hence, we're starting off the video by cloning a Gradle project, which has said Gradle wrapper enabled. We're going to take a look at how to use the wrapper, what files and folders it consists of, and the differences to a global Gradle installation.
Up next, we'll need to dissect the settings.gradle
file. Every Gradle project has one at the root of its project structure. It contains data like the name of the overall project, as well as all sub-projects (or modules). By the way, the example project from the video uses multiple sub-projects to make it more realistic.
Once you have a solid understanding of Gradle's directory structure (which is very similar to Maven's default directory layout), we can start running some popular Gradle commands. From gradlew build,
to gradlew test
and gradlew clean
, we'll cover the three most important commands in your day-to-day work-life.
What makes Gradle so great, however, is its built-in smartness features. It knows when/how to rebuild modules, saving you time in the process! We'll quickly cover those features by looking at what happens when you re-run tests multiple times.
Most importantly, every project nowadays uses third-party dependencies, which begs the question, "How do you find and add said dependencies to a Gradle project?" We'll have a look at a package search machine and will then add new dependencies to our project, making sure to cover possible pitfalls when using an IDE.
Dependencies, as is the case with Maven, come with different scopes. We'll cover the implementation
, testImplementation
, and api
scopes, as well as other scopes that were available in legacy versions of Gradle and how you would migrate between those scopes.
Up next, a big part of Gradle projects are plugins, as well as repositories. We'll cover plugins and how to find and apply them to your project, as well as what kind of repositories you can use with your Gradle project.
One of the major issues with Gradle is that sooner or later you will end up with an error message you will have to interpret correctly or spend countless hours on Stack Overflow to find the right answer. We'll talk a bit about this and how to get comfortable with reading Gradle stack traces.
Last but not least, it's about applying your new knowledge immediately and creating a Gradle project, completely from scratch! For that, you'll have to install Gradle, which then allows you to use its project wizard, which will create a project skeleton, including the Gradle wrapper, for you.
If you managed to watch the entire video, you'll be presented with some hints, tips, and resources, that will help you continue your Gradle learning journey on your own. Check it out and let us know what you think!
Opinions expressed by DZone contributors are their own.
Comments