Gradle official website link: https://gradle.org/
1. Download the source file
Download link: https://services.gradle.org/distributions/ It is
recommended that you choose the gradle-XXX-all.zip file when downloading. If it is just for use, it is no problem to choose to download gradle-XXX-bin.zip , But we may encounter some weird problems when developing, we need to look at the source code of gradle, and XXX-all.zip contains the source code, personal suggestion, for your reference only!
Here I choose to download gradle-6.6.1-all.zip, which is not the latest version. At this time, the latest version is already gradle-6.8, but for stability, we try to choose the more mature version before!
2. Configure environment variables
- New variables in the system environment variables
GRADLE_HOME
andGRADLE_USER_HOME
two system variables, and configure the appropriate value based on the position of their gradle storage. - Add a new entry to the path and add the following content:
%GRADLE_HOME%\bin
- Save and exit the last way!
3. Verify that the installation is successful
Enter in the cmd command line:gradle -v
4. Gradle usage configuration in specific projects
After we import the Gradle project in idea, we generally do the following configuration
- Modify the
gradle-wrapper.properties
file,
comment outdistributionUrl
the value in the source project , and add local configuration information
# 注意,格式如下:
distributionUrl=file:///+你的Gradle的zip放置目录,注意层级之间用/而不是\ ,下面是配置的实例!
distributionUrl=file:///D:/gradle/gradle-6.6.1-all.zip
- Modify the build.gradle file, find the following code snippet, and add the Alibaba Cloud image (if you don’t add it, you won’t be able to complete the component in a few hours)
Recommended learning address : https://developer.aliyun.com/article/754038?spm=a2c6h.13813017.0.dArticle738638.5d541338iPK04P
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
mavenLocal()
mavenCentral()
}
}