Gradle 使用

安装

官网上有详细的安装介绍,支持 sdk,brew, scoop 或者手动安装。如果没有前面这些包管理工具,直接手动安装是更好的选择。

下载地址:https://gradle.org/releases,选择最新的稳定版本即可。

下载之后,解压缩到一个目录。

将bin目录加到path下。然后打开一个命令行窗口,试试 gradle。

配置

  • 代理

在build.gradle 同一级目录下创建 gradle.properties 文件。并准备如下内容

systemProp.http.proxyHost=proxy-host.com
systemProp.http.proxyPort=proxy-port
systemProp.https.proxyHost=proxy-host.com
systemProp.https.proxyPort=proxy-port

命令

https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html

  • gradle build
    构建,下载依赖lib
  • gradle tasks 列出可用的task
  • gradle --continuous myTask 当代码改动时,自动重新执行任务,从 2.5 开始支持。

When you run with the --continuous or -t command line options, Gradle will not exit at the end of a build. Instead, Gradle will wait for files that are processed by the build to change. When changes are detected, Gradle will re-run the previous build with the same task selection.

参考

官方 userguide

原文地址:https://www.cnblogs.com/Rexxar/p/6872487.html