To have nice test logs in Gradle #

plugins {
    id 'com.adarshr.test-logger' version '3.0.0'


To run any version of gradle using a docker container #

It facilitates running gradle from a linux environment. See bellow two examples combining different versions of Java and Gradle:

# Gradle 6 and Java 8
docker run --rm -u gradle -v "$PWD":/home/gradle/project \ 
  -w /home/gradle/project gradle:6-jdk8 gradle test
# Gradle 7 and Java 16
docker run --rm -u gradle -v "$PWD":/home/gradle/project \
  -w /home/gradle/project gradle:7-jdk16 gradle test

How to make the gradle test runner fail fast #

./gradlew test --fail-fast

Skipping tests (or any other task) #

./gradlew build -x test

Filtering tests in gradle #

 ./gradle test --tests "*SubscriptionTest*"

Integrate gradle with #

When you have a maven project with the maven-jar-compilerplugin configured to publish the test folder (type test-jar), maven will publish the production jar and also the test-jar. You can import the test-jar using a Gradle classifier. Example:

testImplementation ''

So, there will be library-common-1.0.0.jar and library-common-1.0.0-tests.jar in the repository available to gradle, and it will use the one specified in the classifier.

Excluding transitive dependencies #

From entire classpath:

configurations {
    all {

From the testImplementation classpath:

configurations {
    testImplementation {

From the added dependency itself:

api(project(":myproject")) {

Gradle Enterprise #

Debugging cache operations when using the Gradle Maven Extension #

And also debug to find out why a cache was missed:

mvn clean verify -Dorg.slf4j.simpleLogger.log.gradle.goal.cache=debug  -Dgradle.scan.captureGoalInputFiles=true