Linux command
gradle-wrapper 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate wrapper
gradle wrapper
Specify Gradle version
gradle wrapper --gradle-version [9.4.0]
Use distribution type (bin or all)
gradle wrapper --distribution-type [all]
Upgrade wrapper version using existing wrapper
./gradlew wrapper --gradle-version [9.4.0]
Specify distribution with SHA-256 verification
gradle wrapper --gradle-version [9.4.0] --gradle-distribution-sha256-sum [checksum]
Run project build with wrapper
./gradlew build
说明
gradle wrapper generates the Gradle Wrapper, enabling projects to use a specific Gradle version without requiring a global installation. Users run ./gradlew instead of gradle, and the wrapper downloads and uses the specified version automatically. This ensures consistent builds across different machines and CI systems by pinning the exact Gradle version in source control.
参数
- --gradle-version _VERSION_
- Gradle version to use.
- --distribution-type _TYPE_
- bin or all (includes sources).
- --gradle-distribution-url _URL_
- Custom distribution URL.
- --gradle-distribution-sha256-sum _HASH_
- SHA-256 checksum for distribution verification.
- --help
- Display help information.
FAQ
What is the gradle-wrapper command used for?
gradle wrapper generates the Gradle Wrapper, enabling projects to use a specific Gradle version without requiring a global installation. Users run ./gradlew instead of gradle, and the wrapper downloads and uses the specified version automatically. This ensures consistent builds across different machines and CI systems by pinning the exact Gradle version in source control.
How do I run a basic gradle-wrapper example?
Run `gradle wrapper` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --gradle-version _VERSION_ do in gradle-wrapper?
Gradle version to use.