Gradle 2.14.1 用户指南翻译——第三章. 安装Gradle

本文详细介绍了如何安装Gradle,包括先决条件(Java版本要求)、下载发行包、解压、设置环境变量(GRADLE_HOME和PATH)、运行和测试安装过程,以及如何通过GRADLE_OPTS或JAVA_OPTS设置JVM选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

翻译项目请关注Github上的地址:GitHub - msdx/gradledoc: Gradle 中文文档 。

本文翻译所在分支: GitHub - msdx/gradledoc at 2.14.1
更好的阅读体验请访问:Gradle 用户指南版本 2.14.1 - Gradle User Guide Version 2.14.1

最新完成的完整翻译请查看2.0版本Gradle 用户指南 - Gradle User Guide

翻译不易,本文采用 CC BY-NC-SA 4.0 许可协议,转载请务必署名及注明本文在CSDN博客上的出处:

https://coder.blog.csdn.net/article/details/134505518

关于我对Gradle的翻译,以Github上的项目及http://gradledoc.githang.com 上的文档为准。如发现翻译有误的地方,将首先在以上两个地方更新。因时间精力问题,博客中发表的译文基本不会同步修改。

第三章. 安装Gradle

Chapter 3. Installing Gradle

目录
Table of Contents

3.1. 先决条件 - Prerequisites

3.2. 下载 - Download

3.3. 解压 - Unpacking

3.4. 环境变量 - Environment variables

3.5. 运行和测试安装 - Running and testing your installation

3.6. JVM 选项 - JVM options

3.1. 先决条件

3.1. Prerequisites

Gradle 需要安装 Java 6 或更高版本的 JDK 或 JRE,(可以使用java -version来检查)。 Gradle 附带了自己的 Groovy 库,因此不需要安装 Groovy。已经安装的 Groovy 会被 Gradle 所忽略。
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 使用在你的的 path 变量中找到的 JDK。或者,你也可以设置JAVA_HOME环境变量来指向所需的 JDK 的安装目录。
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.

3.2. 下载

3.2. Download

你可以从Gradle 官方网站上下载Gradle的发行包。
You can download one of the Gradle distributions from the Gradle web site.

3.3. 解压

3.3. Unpacking

Gradle的发行包是一个 ZIP 文件。完整的发行包包含:
The Gradle distribution comes packaged as a ZIP. The full distribution contains:

  • Gradle 可执行文件。

    The Gradle binaries.

  • 用户指南( HTML 和 PDF 两种版本)。

    The user guide (HTML and PDF).

  • DSL 参考指南。

    The DSL reference guide.

  • API 文档(包括 Javadoc 和 Groovydoc)。

    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.

  • 源代码。这些源代码仅供参考。如果你想自己来构建 Gradle,则需要去下载源码发行包,或者是从源码仓库里检出代码。具体请参阅Gradle 官方网站

    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 the Gradle web site for details.

3.4. 环境变量

3.4. Environment variables

要运行 Gradle,请先添加环境变量 GRADLE_HOME。它应该指向 Gradle 网站上解压缩的文件。接下来,将 GRADLE_HOME/bin 添加到 PATH 环境变量中。通常,这样就可以运行 Gradle 了。
For running Gradle, firstly add the environment variable GRADLE_HOME. This should point to the unpacked files from the Gradle website. Next add GRADLE_HOME/bin to your PATH environment variable. Usually, this is sufficient to run Gradle.

3.5. 运行和测试安装

3.5. Running and testing your installation

你可以通过 gradle 命令来运行 Gradle。输入 gradle -v 就可以检查 Gradle 是否正确安装。该命令会输出 Gradle 的版本,以及本地环境配置(groovy 和 JVM 版本等等)。所显示的 Gradle 版本应与你下载的发行包相匹配。
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.

3.6. JVM 选项

3.6. JVM options

运行 Gradle 的 JVM 参数可以通过环境变量 GRADLE_OPTS 或 JAVA_OPTS 来设置,这两者也可以一起使用。按照惯例,JAVA_OPTS 是一个许多 Java 应用程序共享的环境变量。一个典型的场景是在 JAVA_OPTS 中设置 HTTP 代理,而在 GRADLE_OPTS 中设置内存选项。这些环境变量也可以在 gradle 或 gradlew 脚本文件的开头设置。
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 the gradle or gradlew script.

请注意,目前无法在命令行上为 Gradle 设置 JVM 选项。
Note that it's not currently possible to set JVM options for Gradle on the command line.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值