Skip to content

Instantly share code, notes, and snippets.

@jiffle
Forked from qrman/GradleCheatsheet.md
Last active April 14, 2024 10:00
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save jiffle/499caa5f53ab8f90dc19a3040ee40f48 to your computer and use it in GitHub Desktop.
Save jiffle/499caa5f53ab8f90dc19a3040ee40f48 to your computer and use it in GitHub Desktop.
Cheatsheet of Gradle Commands and Config

Command Cheatsheet

  • Convert Maven build to gradle

    gradle init

  • Initialise new project folder structure (Java example)

    gradle init --type java-library

  • List all projects in the build

    gradle -q projects

  • List all properties on the build

gradle -q properties

  • List build configuration model

    gradle -q model

  • Execute one integration test:

    ./gradlew integrationTest --tests=*SomeTestClass

  • Execute tasks parallel:

    ./gradlew clean build --parallel

  • Skip test:

    gradle build -x test

  • Include console and logging output for container code and tests

    gradle functionalTest --info

  • Run application tests with debugger agent

    gradle test --debug-jvm

  • Refresh dependencies

    ./gradlew clean build --refresh-dependencies

  • View dependencies for specific jar (and configuration)

    gradle my-sub-project:dependencyInsight --configuration testCompile --dependency hamcrest-core

  • Run in custom environment

    -Dspring.profiles.active=dev

Configuration Cheatsheet

  • Better logging in tests:
test {
    testLogging {
        exceptionFormat = 'full'
    }
}
@coulid
Copy link

coulid commented Jun 12, 2022

How can I add jvm options and java compiler options in gradle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment