Gradle 命令行介紹和安裝教程
Gradle 命令行
$ gradle -h
USAGE: gradle [option...] [task...]
-?, -h, --help Shows this help message.
-a, --no-rebuild Do not rebuild project dependencies.
-b, --build-file Specify the build file.
--build-cache Enables the Gradle build cache. Gradle will try to reuse outputs from previous builds.
-c, --settings-file Specify the settings file.
--configuration-cache Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds. [incubating]
--configuration-cache-problems Configures how the configuration cache handles problems (fail or warn). Defaults to fail. [incubating]
--configure-on-demand Configure necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds. [incubating]
--console Specifies which type of console output to generate. Values are 'plain', 'auto' (default), 'rich' or 'verbose'.
--continue Continue task execution after a task failure.
-D, --system-prop Set system property of the JVM (e.g. -Dmyprop=myvalue).
-d, --debug Log in debug mode (includes normal stacktrace).
--daemon Uses the Gradle Daemon to run the build. Starts the Daemon if not running.
--export-keys Exports the public keys used for dependency verification. [incubating]
-F, --dependency-verification Configures the dependency verification mode (strict, lenient or off) [incubating]
--foreground Starts the Gradle Daemon in the foreground.
-g, --gradle-user-home Specifies the gradle user home directory.
-I, --init-script Specify an initialization script.
-i, --info Set log level to info.
--include-build Include the specified build in the composite.
-M, --write-verification-metadata Generates checksums for dependencies used in the project (comma-separated list) [incubating]
-m, --dry-run Run the builds with all task actions disabled.
--max-workers Configure the number of concurrent workers Gradle is allowed to use.
--no-build-cache Disables the Gradle build cache.
--no-configuration-cache Disables the configuration cache. [incubating]
--no-configure-on-demand Disables the use of configuration on demand. [incubating]
--no-daemon Do not use the Gradle daemon to run the build. Useful occasionally if you have configured Gradle to always run with the daemon by default.
--no-parallel Disables parallel execution to build projects.
--no-scan Disables the creation of a build scan. For more information about build scans, please visit https://gradle.com/build-scans.
--no-watch-fs Disables watching the file system. [incubating]
--offline Execute the build without accessing network resources.
-P, --project-prop Set project property for the build script (e.g. -Pmyprop=myvalue).
-p, --project-dir Specifies the start directory for Gradle. Defaults to current directory.
--parallel Build projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.
--priority Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Values are 'normal' (default) or 'low' [incubating]
--profile Profile build execution time and generates a report in the <build_dir>/reports/profile directory.
--project-cache-dir Specify the project-specific cache directory. Defaults to .gradle in the root project directory.
-q, --quiet Log errors only.
--refresh-dependencies Refresh the state of dependencies.
--refresh-keys Refresh the public keys used for dependency verification. [incubating]
--rerun-tasks Ignore previously cached task results.
-S, --full-stacktrace Print out the full (very verbose) stacktrace for all exceptions.
-s, --stacktrace Print out the stacktrace for all exceptions.
--scan Creates a build scan. Gradle will emit a warning if the build scan plugin has not been applied. (https://gradle.com/build-scans)
--status Shows status of running and recently stopped Gradle Daemon(s).
--stop Stops the Gradle Daemon if it is running.
-t, --continuous Enables continuous build. Gradle does not exit and will re-execute tasks when task file inputs change.
--update-locks Perform a partial update of the dependency lock, letting passed in module notations change version. [incubating]
-v, --version Print version info.
-w, --warn Set log level to warn.
--warning-mode Specifies which mode of warnings to generate. Values are 'all', 'fail', 'summary'(default) or 'none'
--watch-fs Enables watching the file system for changes, allowing data about the file system to be re-used for the next build. [incubating]
--write-locks Persists dependency resolution for locked configurations, ignoring existing locking information if it exists [incubating]
-x, --exclude-task Specify a task to be excluded from execution.
直接gradle
$ gradle
=======================================
Elasticsearch Build Hamster says Hello!
Gradle Version : 6.6.1
OS Info : Mac OS X 10.14.5 (x86_64)
JDK Version : 11 (Oracle JDK)
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home
Random Testing Seed : 81391CAF341C3379
In FIPS 140 mode : false
=======================================
> Task :help
Welcome to Gradle 6.6.1.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
To see more detail about a task, run gradle help --task <task>
For troubleshooting, visit https://help.gradle.org
BUILD SUCCESSFUL in 4s
1 actionable task: 1 executed
gradle build
装配所有输出并运行所有检查
gradle run
运行所有任务
gradle check
验证任务,包括测试和初始化
gradle clean
清理所有输出
gradle projects
项目报告,包括子项目
gradle tasks
所有的tasks列表
gradle -q help –task xxx
展示指定任务的详细信息
gradle buildEnvironment
展示构建环境依赖关系报告
gradle dependencyInsight
展示依赖关系报告
gradle model
展示模型关系报告
gradle dependencies
展示項目依賴。
$ gradle dependencies
<-------------> 0% INITIALIZING [47s]
=======================================
Elasticsearch Build Hamster says Hello!
Gradle Version : 6.6.1
OS Info : Mac OS X 10.14.5 (x86_64)
JDK Version : 11 (Oracle JDK)
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home
Random Testing Seed : 4F74E0BEC4127C06
In FIPS 140 mode : false
=======================================
> Task :dependencies
------------------------------------------------------------
Root project - Elasticsearch subproject :
------------------------------------------------------------
elasticsearch_7.0.0_archive_darwin_default
--- elasticsearch-distribution:elasticsearch:7.0.0
elasticsearch_7.0.0_archive_darwin_oss
--- elasticsearch-distribution:elasticsearch-oss:7.0.0
elasticsearch_7.0.1_archive_darwin_default
--- elasticsearch-distribution:elasticsearch:7.0.1
。。。
es_distro_file_local
--- project :distribution:archives:darwin-tar
es_distro_file_testclusters--runTask-0-8.0.0-SNAPSHOT-
--- project :distribution:archives:darwin-tar
。。。
(*) - dependencies omitted (listed previously)
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 5m 13s
1 actionable task: 1 executed
安裝教程
Installing with a package manager
SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix-based systems.
$ sdk install gradle 6.6.1
Homebrew is “the missing package manager for macOS”.
$ brew install gradle
Other package managers are available, but the version of Gradle distributed by them is not controlled by Gradle, Inc. Linux package managers may distribute a modified version of Gradle that is incompatible or incomplete when compared to the official version (available from SDKMAN! or below).
› Additional helpful information
Installing manually
Step 1. Download the latest Gradle distribution
The current Gradle release is version 6.6.1, released on 25 Aug 2020. The distribution zip file comes in two flavors:
- Binary-only
- Complete, with docs and sources
If in doubt, choose the binary-only version and browse docs and sources online.
Need to work with an older version? See the releases page.
Step 2. Unpack the distribution
Linux & MacOS users
Unzip the distribution zip file in the directory of your choosing, e.g.:
$ mkdir /opt/gradle
$ unzip -d /opt/gradle gradle-6.6.1-bin.zip
$ ls /opt/gradle/gradle-6.6.1
LICENSE NOTICE bin getting-started.html init.d lib media
Microsoft Windows users
Create a new directory C:Gradle
with File Explorer.
Open a second File Explorer window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder gradle-6.6.1
to your newly created C:Gradle
folder.
Alternatively you can unpack the Gradle distribution ZIP into C:Gradle
using an archiver tool of your choice.
Step 3. Configure your system environment
Linux & MacOS users
Configure your PATH
environment variable to include the bin
directory of the unzipped distribution, e.g.:
$ export PATH=$PATH:/opt/gradle/gradle-6.6.1/bin
Microsoft Windows users
In File Explorer right-click on the This PC
(or Computer
) icon, then click Properties
-> Advanced System Settings
-> Environmental Variables
.
Under System Variables
select Path
, then click Edit
. Add an entry for C:Gradlegradle-6.6.1bin
. Click OK to save.
Step 4. Verify your installation
Open a console (or a Windows command prompt) and run gradle -v
to run gradle and display the version, e.g.:
$ gradle -v
------------------------------------------------------------
Gradle 6.6.1
------------------------------------------------------------
› Additional helpful information
Upgrade with the Gradle Wrapper
If your existing Gradle-based build uses the Gradle Wrapper, you can easily upgrade by running the wrapper
task, specifying the desired Gradle version:
$ ./gradlew wrapper --gradle-version=6.6.1 --distribution-type=bin
Note that it is not necessary for Gradle to be installed to use the Gradle wrapper. The next invocation of gradlew
or gradlew.bat
will download and cache the specified version of Gradle.
$ ./gradlew tasks
Downloading https://services.gradle.org/distributions/gradle-6.6.1-bin.zip
...
› Additional helpful information
Older Releases
You can find all releases and their checksums on the releases page.
Command-Line Completion
Command-line completion scripts are available for bash and zsh. This provides completion for Gradle tasks and command-line options.
/elasticsearch$ gradle -v
------------------------------------------------------------
Gradle 6.6.1
------------------------------------------------------------
Build time: 2020-08-25 16:29:12 UTC
Revision: f2d1fb54a951d8b11d25748e4711bec8d128d7e3
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.8 (Oracle Corporation 11.0.8+10-LTS)
OS: Mac OS X 10.14.5 x86_64
參考資料
「1」https://www.cnblogs.com/jpfss/p/9877862.html
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Spring中的设计模式
- java单元/集成测试中使用Testcontainers
- AOP编程简介及其在Spring框架中的使用
- 使用Maven Archetype创建Java项目模板
- left join左表一定是驱动表吗?
- OneFlow快速上手教程
- [译]HAL-超文本应用语言
- OneFlow | 新深度学习框架后浪(附源代码)
- 居民身份证阅读器产品开发学习心得(再谈标准-软件-协议)
- Spring Data REST不完全指南(一)
- Cocos2d-js中的简易MVC框架(五)MVC框架的使用
- [译]谈谈SpringBoot 事件机制
- C++ 模板沉思录(下)
- Cocos2d-js中的简易MVC框架(四)显示层View
- 如何在去中心化交易所中(DEX)集成0x协议