It will be 2023 soon, learn about gradle (Gradle) installation and configuration

Gradle learning

For example: I believe that many companies are already using it, but my friends are still vague about it


Gradle

虽然目前常见的项目构建工具有Ant、Maven、Gradle,主流还是Maven,但是未来趋势可能是Gradle。


1. Introduction to Gradle?

Gradle is a Google project-based JVM, general-purpose and flexible project construction tool that supports multiple third-party warehouses; supports transitive dependency management, discards complicated xml files, and uses concise and multi-language support (for example Maven: etc. ) script file.JCenterjava、groovy build

insert image description here
Official website address: https://gradle.org/
Official download address: https://gradle.org/releases/

Groovy

Gradle Groovywas tested with 1.5.8 to 4.0.0.

GroovyGradle plugins written in must be used Groovy3.xto be compatible with Gradle and GroovyDSLbuild scripts.

2. Common project construction tools

1. Ant : A pure Java-written build tool launched by Apache in 2000, which xmlmanages projects through the [build.xml] file

  • Advantages : 使用灵活,速度快(faster than gradle and maven),
  • Disadvantages : Ant does not impose any coding conventions on the project directory structure, and developers need to write complex XML file construction instructions, which is a challenge for developers.

2. Maven : Launched by the Apache organization in 2004, it is a construction tool that reuses the xml file [pom.xml] to manage projects.

  • Advantages : Follow a set 约定大于配置of project directory structure, use unified GAV coordinates for dependency management, 侧重于包管理.
  • Disadvantages : The project construction process is rigid, the configuration file is not flexible enough, and it is not convenient to customize components 构建速度慢于 gradle.

3. Gradle : A new project construction tool based on the Groovy language launched by Google in 2012 集合了Ant 和 Maven 各自的优势.

  • Advantages : The flexibility of Ant script + Maven convention is greater than the advantage of configured project directory, 支持多种远程仓库和插件focusing on large project construction.
  • Disadvantages : 学习成本高、资料少、脚本灵活、版本兼容性poor and so on.

Three, gradle installation

Gradle must first install JDK. If it is not installed, please refer to: Installing JDK
requires JDK version 1.8 or above.
Check the JDK version

java - version (If you don't look at the picture below, you must have installed it and it won't work)

Check the Gradle version adapted to IDEA (敲黑板--------------看这里)
Find the IDEA installation directory >>>plugins (plug-in folder) >>>gradle>>>lib>>>Check the Gradle version

D:\newsoft\IntelliJ IDEA 2019.3.2\plugins\gradle\lib

insert image description here
(文中版本截图,杂乱是因为我安装了好多个版本,不要放在心上,注意版本兼容即可)

The corresponding relationship between the Gradle version and the Java version (remember this sentence: always look at the version first when using something 是否兼容)

A Java version between 8 and 19 is required to execute Gradle. Java 20
and later versions are not yet supported.

Java 6 and 7 can still be used for compilation, but are deprecated for
use with testing. Testing with Java 6 and 7 will not be supported in
Gradle 9.0.

Any fully supported version of Java can be used for compile or test.
The latest Java version may however only be supported for compile or
test but not yet for running Gradle.

For older Gradle versions, please see the table below which Java
version is supported by which Gradle release.

Java version Gradle version
8 2.0
9 4.3
10 4.7
11 5.0
12 5.4
13 6.0
14 6.3
15 6.7
16 7.0
17 7.3
18 7.5
19 7.6

1. Download

Official download address: https://gradle.org/releases/
(picture):
insert image description here
Unzip to the specified directory: D:\newsoft\gradle-6.5

2. Configuration (environment variables)

2.1, open the environment variable

insert image description here

2.2, Create a new environment variable

GRADLE_HOME
D:\newsoft\gradle-6.5 (depending on where you store it)
insert image description here

2.3. Create a new one in the Path variable:

Edit Path

in the last line

%GRADLE_HOME%;

insert image description here

2.4, Create a new local warehouse

insert image description here

2.5. Set environment variables for the warehouse directory

GRADLE_USER_HOME

insert image description here

test

binEnter the gradle directory we installed

insert image description here
insert image description here

Enter :gradle -v

insert image description here
Successful installation.

If you want to install multiple versions of JDK, please see this article : https://blog.csdn.net/aaxzsuj/article/details/128122537
insert image description here

Guess you like

Origin blog.csdn.net/aaxzsuj/article/details/128118668