Spring Boot 项目构建 之 安装 Gradle(Chapter 4. Installing Gradle)

简介: 白话解析如下:===========Mac 系统下载到 Gradle 压缩包后,解压到某一目录下,然后设置环境变量,命令如下:vi ~/.profile 按 i 进行编辑模式,用方向键向下移动光标到末尾,并添加如下内容:export GRADLE_HOME=/xxx/yyy/.../gradle-2.5export PATH=$GRADLE_HOME/bin:$PATH按 ESC 键退出编辑模式,输入 w 回车保存,再输入 q 回车退出 vi 编辑器。


白话解析如下:

===========

Mac 系统下载到 Gradle 压缩包后,解压到某一目录下,然后设置环境变量,命令如下:

vi ~/.profile 

按 i 进行编辑模式,用方向键向下移动光标到末尾,并添加如下内容:

export GRADLE_HOME=/xxx/yyy/.../gradle-2.5
export PATH=$GRADLE_HOME/bin:$PATH

按 ESC 键退出编辑模式,输入 w 回车保存,再输入 q 回车退出 vi 编辑器。

接下来测试 gradle 是否可用,新开一个终端即命令行窗口,输入:

gradle -v

回车执行后,会出现如下内容,表示已成功安装可用:

------------------------------------------------------------
Gradle 2.5
------------------------------------------------------------

Build time:   2015-07-08 07:38:37 UTC
Build number: none
Revision:     093765bccd3ee722ed5310583e5ed140688a8c2b

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_40 (Oracle Corporation 25.40-b25)
OS:           Mac OS X 10.10.4 x86_64


4.1. Prerequisites

Gradle requires a Java JDK or JRE to be installed, version 6 or higher (to check, use java -version). Gradle ships with its own Groovy library, therefore Groovy does not need to be installed. Any existing Groovy installation is ignored by Gradle.

Gradle uses whatever JDK it finds in your path. Alternatively, you can set the JAVA_HOME environment variable to point to the installation directory of the desired JDK.

4.2. Download

You can download one of the Gradle distributions from the Gradle web site.

4.3. Unpacking

The Gradle distribution comes packaged as a ZIP. The full distribution contains:

  • The Gradle binaries.

  • The user guide (HTML and PDF).

  • The DSL reference guide.

  • The API documentation (Javadoc and Groovydoc).

  • Extensive samples, including the examples referenced in the user guide, along with some complete and more complex builds you can use as a starting point for your own build.

  • The binary sources. This is for reference only. If you want to build Gradle you need to download the source distribution or checkout the sources from the source repository. See theGradle web site for details.

4.4. Environment variables

For running Gradle, add GRADLE_HOME/bin to your PATH environment variable. Usually, this is sufficient to run Gradle.

4.5. Running and testing your installation

You run Gradle via the gradle command. To check if Gradle is properly installed just type gradle -v. The output shows the Gradle version and also the local environment configuration (Groovy, JVM version, OS, etc.). The displayed Gradle version should match the distribution you have downloaded.

4.6. JVM options

JVM options for running Gradle can be set via environment variables. You can use either GRADLE_OPTS or JAVA_OPTS, or both. JAVA_OPTS is by convention an environment variable shared by many Java applications. A typical use case would be to set the HTTP proxy in JAVA_OPTS and the memory options in GRADLE_OPTS. Those variables can also be set at the beginning of thegradle or gradlew script.

Note that it's not currently possible to set JVM options for Gradle on the command line.


3.1. Getting Started

The following tutorials introduce some of the basics of Gradle, to help you get started.

Chapter 4, Installing Gradle

Describes how to install Gradle.

Chapter 6, Build Script Basics

Introduces the basic build script elements: projects and tasks.

Chapter 7, Java Quickstart

Shows how to start using Gradle's build-by-convention support for Java projects.

Chapter 8, Dependency Management Basics

Shows how to start using Gradle's dependency management.

Chapter 9, Groovy Quickstart

Using Gradle's build-by-convention support for Groovy projects.

Chapter 10, Web Application Quickstart

Using Gradle's build-by-convention support for Web applications.


The latest release of Gradle is version 2.5, released on 8th July 2015.










目录
相关文章
|
4天前
|
Java API 微服务
【Spring Boot系列】通过OpenAPI规范构建微服务服务接口
【4月更文挑战第5天】通过OpenAPI接口构建Spring Boot服务RestAPI接口
23 0
|
14天前
|
Java Linux
Springboot 解决linux服务器下获取不到项目Resources下资源
Springboot 解决linux服务器下获取不到项目Resources下资源
|
21天前
|
Java API Spring
SpringBoot项目调用HTTP接口5种方式你了解多少?
SpringBoot项目调用HTTP接口5种方式你了解多少?
71 2
|
21天前
|
前端开发 JavaScript Java
6个SpringBoot 项目拿来就可以学习项目经验接私活
6个SpringBoot 项目拿来就可以学习项目经验接私活
33 0
|
25天前
|
Java 应用服务中间件 Maven
SpringBoot 项目瘦身指南
SpringBoot 项目瘦身指南
40 0
|
1月前
|
前端开发 Java 关系型数据库
SpringBoot+MyBatis 天猫商城项目
SpringBoot+MyBatis 天猫商城项目
54 1
|
24天前
|
Java Maven 微服务
springboot项目开启远程调试-jar包
springboot项目开启远程调试-jar包
19 0
|
5天前
|
安全 Java 应用服务中间件
江帅帅:Spring Boot 底层级探索系列 03 - 简单配置
江帅帅:Spring Boot 底层级探索系列 03 - 简单配置
9 0
江帅帅:Spring Boot 底层级探索系列 03 - 简单配置
|
7天前
|
XML Java C++
【Spring系列】Sping VS Sping Boot区别与联系
【4月更文挑战第2天】Spring系列第一课:Spring Boot 能力介绍及简单实践
29 0
【Spring系列】Sping VS Sping Boot区别与联系
|
11天前
|
JSON 前端开发 Java
统一异常处理:让Spring Boot项目异常更优雅
统一异常处理:让Spring Boot项目异常更优雅
23 1

热门文章

最新文章