Gradle 命令行
代码语言:javascript复制$ 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
代码语言:javascript复制$ 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
展示項目依賴。
代码语言:javascript复制$ 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
安裝教程
https://gradle.org/install/
Installing with a package manager
SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix-based systems.
代码语言:javascript复制$ sdk install gradle 6.6.1
Homebrew is “the missing package manager for macOS”.
代码语言:javascript复制$ 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.:
代码语言:javascript复制$ 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.
代码语言:javascript复制/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