Skip to content

Gradle

Task Commands:

Task Description
gradle tasks Display the available tasks.
gradle clean Clean the project.
gradle build Build the project.
gradle test Run tests.
gradle run Run the application.
gradle install Install the project to the local repository.
gradle assemble Assemble the project.
gradle deploy Deploy the project.
gradle clean build Clean and build the project.
gradle clean test Clean and run tests.
gradle clean run Clean and run the application.

Project Configuration:

Item Description
build.gradle Build script configuration file.
src/ Directory containing source code.
build/ Directory containing build output.
src/test/ Directory containing test source code.
src/main/resources/ Directory containing resources.
src/main/java/ Directory containing main Java source code.

Dependencies:

dependencies {   - Define project dependencies in the build script.
    implementation 'group:artifact:version' - Add a dependency.
}

Plugins:

plugins {         - Apply plugins in the build script.
    id 'plugin-id' - Apply a plugin by ID.
}

Task Definitions:

task taskName {    - Define a custom task in the build script.
    // Task configuration
}

Task Dependencies:

task taskName(dependsOn: ['task1', 'task2']) {    - Define task dependencies.
    // Task configuration
}

Build Types:

buildTypes {       - Define different build types (e.g., debug, release).
    debug {        - Define a specific build type.
        // Configuration for the debug build type
    }
    release {
        // Configuration for the release build type
    }
}

Build Variants:

flavorDimensions 'dimensionName'  - Define flavor dimensions.
productFlavors {                  - Define product flavors.
    flavorName {                   - Define a specific product flavor.
        // Configuration for the flavor
    }
}

Repository Configuration:

repositories {    - Define project repositories in the build script.
    mavenCentral()  - Add Maven Central repository.
    jcenter()      - Add JCenter repository.
    maven {        - Add a custom Maven repository.
        url 'repository-url'
    }
}

Gradle Wrapper:

Item Description
gradlew Gradle wrapper script (Unix-like).
gradlew.bat Gradle wrapper script (Windows).
gradle/wrapper/gradle-wrapper.properties Wrapper configuration file.
gradle/wrapper/gradle-wrapper.jar Wrapper JAR file.

Additional Gradle Commands:

Item Description
gradle properties Display project properties and settings.
gradle tasks --all Display all available tasks (including hidden tasks).
gradle dependencies Display project dependencies.
gradle help Display Gradle help.
gradle build --dry-run Perform a dry run of the build without executing tasks.

Gradle Daemon:

Item Description
gradle --daemon Start a Gradle daemon for faster builds.
gradle --no-daemon Disable the Gradle daemon.

Gradle Wrapper Commands:

Command Description
./gradlew tasks Execute Gradle tasks using the wrapper (Unix-like).
gradlew tasks Execute Gradle tasks using the wrapper (Windows).