← 返回命令列表

Linux command

gradle 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Build project

gradle build

Run tests

gradle test

Clean and rebuild

gradle clean build

List available tasks

gradle tasks

Build with parallel execution

gradle build --parallel

Run with a build scan

gradle build --scan

Use the configuration cache

gradle build --configuration-cache

Use a specific build file

gradle -b [path/to/build.gradle] build

说明

gradle is a build automation tool for Java, Kotlin, Android, and other JVM projects. It uses Groovy or Kotlin DSL for build scripts and provides dependency management, incremental builds, and an extensive plugin ecosystem. Gradle is the standard build system for Android development and supports multi-project builds. The Gradle daemon runs persistently in the background to improve build performance and is enabled by default. In most projects, the Gradle Wrapper (`./gradlew`) is preferred over invoking `gradle` directly to ensure consistent build tool versions.

参数

--daemon
Use Gradle daemon (enabled by default).
--no-daemon
Do not use the Gradle daemon.
-q, --quiet
Log errors only.
-i, --info
Set log level to info.
-d, --debug
Set log level to debug.
--parallel
Build projects in parallel.
--configuration-cache
Enable the configuration cache for faster repeat builds.
--scan
Create a build scan at scans.gradle.com.
-b, --build-file _file_
Specify the build file.
-c, --settings-file _file_
Specify the settings file.
--refresh-dependencies
Refresh the state of dependencies.
-x, --exclude-task _task_
Exclude a task from execution.
--continuous
Continuous build; re-execute on file changes.
--help
Display help information.

FAQ

What is the gradle command used for?

gradle is a build automation tool for Java, Kotlin, Android, and other JVM projects. It uses Groovy or Kotlin DSL for build scripts and provides dependency management, incremental builds, and an extensive plugin ecosystem. Gradle is the standard build system for Android development and supports multi-project builds. The Gradle daemon runs persistently in the background to improve build performance and is enabled by default. In most projects, the Gradle Wrapper (`./gradlew`) is preferred over invoking `gradle` directly to ensure consistent build tool versions.

How do I run a basic gradle example?

Run `gradle build` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --daemon do in gradle?

Use Gradle daemon (enabled by default).