How to build Gradle projects with GitHub Actions

If you have a Gradle project in GitHub, then GitHub Actions can build it automatically on push with minimal setup. And it won’t cost you a penny. While other CI solutions involve the headache of managing servers, GitHub Actions is entirely hosted on their infrastructure. In this article you’ll learn how to easily build Gradle projects with GitHub Actions, optimise build performance, and use the event driven approach to handle common scenarios like PR creation....

Published 22 Nov 2021 · 18 min read · Tom Gregory

The 6 best Gradle tutorials for beginners

So you want to get started with Gradle but you’re not sure where to begin? Here you’ll discover the 6 best Gradle tutorials for beginners, compared so you can pick the one to help you move forward with this build automation tool. If you’re looking for a feel-good article about all the great Gradle tutorials out there, this is not it. From my research, helpful Gradle tutorials are rare, and most of them have code examples that don’t work on the latest Gradle version....

Published 4 Oct 2021 · 11 min read · Tom Gregory

Gradle Tutorial for Complete Beginners

Have you heard of Gradle, but you’re not really sure what it is, why you should use it, and how to get started? This tutorial answers all of these questions and helps you take your first steps with this powerful build tool. In this Gradle tutorial you’ll learn: why we need help from build tools to build Java applications why Gradle is a great choice for building Java applications (better than Maven or custom scripts)...

Published 2 Oct 2021 · 22 min read · Tom Gregory

Gradle Build Command

Running the Gradle build command builds your Gradle project, including assembling your application and running tests. Discover all the ways to run the Gradle build command, how it works, as well as why it might sometimes be best not to run it. How to run the Gradle build command Simply put, to build your application run the following command at your Windows command prompt. gradlew build Or if you’re working in a Linux/Mac environment, it’s this....

Published 28 Sep 2021 · 5 min read · Tom Gregory

Running integration tests in Gradle

Your Gradle project can easily be setup to run integration tests using a specific Gradle task and source directory. This separates the integration tests from unit tests, making the project easier to understand and helping developers to work more productively. In this article you’ll learn the simplest way to run integration tests in your Gradle project by adding just a few lines of code to your build script. Benefits of integration tests Integration tests are just one part of an overall testing strategy....

Published 23 Sep 2021 · 7 min read · Tom Gregory

How to Exclude Gradle Dependencies

Certain combinations of transitive dependencies in a Java project cause compile and runtime issues. Fortunately, Gradle has several ways to exclude those unwanted dependencies from the Java classpath to fix your project. In this article you’ll learn the common reasons you’d want to exclude dependencies and how to use each of Gradle’s exclude strategies. Why Exclude Dependencies? When you declare a dependency in your build script, Gradle automatically pulls any transitive dependencies (dependencies of that dependency) into your project....

Updated 1 Nov 2023 · 11 min read · Tom Gregory

5 reasons to switch to the Gradle Kotlin DSL

Gradle versions 5.0+ feature the Kotlin DSL, where you define your build script using the Kotlin language from JetBrains. Whilst the Groovy DSL is more common, there are some advantages in using Kotlin. Here are the top 5 reasons to switch to the Gradle Kotlin DSL. 1) Simplified plugins syntax Gradle comes with built in plugins that you apply to a project by specifying the plugin id only. No version is required....

Published 22 Jul 2021 · 6 min read · Tom Gregory

10 Gradle best practices to supercharge your project

When you use a build tool like Gradle, there are often many ways to do the same thing. How can you decide? Experience counts for a lot, but for something more practical I’ve compiled this list of 10 essential Gradle best practices. If you incorporate these into your project, you’ll have a good chance of success. 1. Always use the Gradle wrapper The wrapper is a special script included in your project which handles downloading the correct Gradle version and executing a build....

Published 7 Jul 2021 · 12 min read · Tom Gregory

Gradle Task Inputs and Outputs

Declaring Gradle task inputs and outputs is essential for your build to work properly. By telling Gradle what files or properties your task consumes and produces, the incremental build feature kicks in, improving the performance of your build. You’ll also be following best practices, allowing you to easily create more complex projects. In this article, you’ll learn how Gradle task inputs and outputs work, why they’re important, as well as practically how to implement them in your own projects....

Updated 9 Jan 2024 · 13 min read · Tom Gregory