Gradle应用简介

news/2024/5/20 1:39:18 标签: gradle

1. 存储库

默认情况下,Gradle不定义任何存储库。我们必须至少明确地定义一个存储库。

2. 显示帮助信息

$ gradle --help

  执行 gradle --help 可查看gradle命令语法及各选项意义,如下:

$ gradle --help

USAGE: gradle [option...] [task...]

-?, -h, --help            Shows this help message.
-a, --no-rebuild          Do not rebuild project dependencies. [deprecated]
-b, --build-file          Specify the build file.
--build-cache             Enables the Gradle build cache. Gradle will try to reuse outputs from previous builds. [incubating]
-c, --settings-file       Specify the settings file.
--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.
--foreground              Starts the Gradle Daemon in the foreground. [incubating]
-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. [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. [incubating]
--no-build-cache          Disables the Gradle build 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. [incubating]
--no-scan                 Disables the creation of a build scan. For more information about build scans, please visit https://gradle.com/build-scans. [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. [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.
--recompile-scripts       Force build script recompiling. [deprecated]
--refresh-dependencies    Refresh the state of dependencies.
--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) [incubating]
--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. [incubating]
-u, --no-search-upward    Don't search in parent folders for a settings file.
-v, --version             Print version info.
-w, --warn                Set log level to warn.
-x, --exclude-task        Specify a task to be excluded from execution.

  语法,启动一个构建:

$ gradle <task> ...

  选项,如:
- -continue选项使发生故障时继续执行
- -b选项选择执行哪些构,可以使用选择指定的构建文件的路径。

3. 列出项目下可执行的所有任务

$ gradle tasks
# or
$ gradle -q tasks

  执行gradle -q tasks可看到一个Gradle项目中常用的任务(命令)如下:

$ gradle -q tasks
# 输出:
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
jar - Assembles a jar archive containing the main classes.
testClasses - Assembles test classes.
war - Generates a war archive with all the compiled classes, the web-app content and the libraries.

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'gradleWebApp'.
components - Displays the components produced by root project 'gradleWebApp'. [incubating]
dependencies - Displays all dependencies declared in root project 'gradleWebApp'.
dependencyInsight - Displays the insight into a specific dependency in root project 'gradleWebApp'.
dependentComponents - Displays the dependent components of components in root project 'gradleWebApp'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'gradleWebApp'. [incubating]
projects - Displays the sub-projects of root project 'gradleWebApp'.
properties - Displays the properties of root project 'gradleWebApp'.
tasks - Displays the tasks runnable from root project 'gradleWebApp'.

Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

Web application tasks
---------------------
tomcatJasper - Runs the JSP compiler and turns JSP pages into Java source.
tomcatRun - Uses your files as and where they are and deploys them to Tomcat.
tomcatRunWar - Assembles the webapp into a war and deploys it to Tomcat.
tomcatStop - Stops Tomcat.

Rules
-----
Pattern: clean<TaskName>: Cleans the output files of a task.
Pattern: build<ConfigurationName>: Assembles the artifacts of a configuration.
Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.

To see all tasks and more detail, run gradle tasks --all

To see more detail about a task, run gradle help --task <task>

4. 查看某一个任务的详细信息

$ gradle help --task <task>

  如执行gradle help --task tomcatRun可看到tomcatRun任务如下:

$ gradle help --task tomcatRun
# 输出:
:help
Detailed task information for tomcatRun

Path
     :tomcatRun

Type
     TomcatRun (com.bmuschko.gradle.tomcat.tasks.TomcatRun)

Description
     Uses your files as and where they are and deploys them to Tomcat.

Group
     web application

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

http://www.niftyadmin.cn/n/823601.html

相关文章

php文件上传参数细节

1&#xff1a;error类型&#xff1a; 1&#xff09;其值为 0&#xff0c;没有错误发生&#xff0c;文件上传成功。 2&#xff09;其值为 1&#xff0c;上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值。 3&#xff09;其值为 2&#xff0c;上传文件的大小超过了…

六年程序生涯

工作六年对一个程序员意味什么&#xff1f;在职位上&#xff1a;高级开发工程师&#xff1f;架构师&#xff1f;技术经理&#xff1f;or … &#xff1f;在能力上&#xff1a;各种编码无压力&#xff1f;核心代码无压力&#xff1f;平台架构无压力&#xff1f; or … fuck&…

一个简单的Gradle脚本文件

通过一个简单的Gradle脚本文件理解其主要语法&#xff1a; // build.gradle 文件 // 建议运行在JDK1.8下&#xff0c;Gradle5.0将不再支持JDK1.7的运行 // Support for running Gradle using Java 7 has been deprecated and is scheduled to be removed in Gradle 5.0.// 定义…

内核符号表System.map

System.map是一个特定内核的内核符号表。它是你当前运行的内核的System.map的链接。 内核符号表是怎么创建的呢? System.map是由“nm vmlinux”产生并且不相关的符号被滤出。对于本文中的例子&#xff0c;编译内核时&#xff0c;System.map创建在/usr/src/linux-2.4/System.ma…

Spark MLlib知识点学习整理

MLlib的设计原理:把数据以RDD的形式表示&#xff0c;然后在分布式数据集上调用各种算法。MLlib就是RDD上一系列可供调用的函数的集合。 操作步骤: 1、用字符串RDD来表示信息。 2、运行MLlib中的一个特征提取算法来吧文本数据转换为数值的特征。给操作会返回一个向量RDD。 3、对…

Gradle仓库

转自&#xff1a;https://docs.gradle.org/4.4.1/userguide/dependency_management.html#sec:repositories 25.6. Repositories Gradle repository management, based on Apache Ivy, gives you a lot of freedom regarding repository layout and retrieval policies. Additi…

linux性能调优工具perf

perf学习-linux自带性能分析工具什么是perf?linux性能调优工具&#xff0c;32内核以上自带的工具&#xff0c;软件性能分析。在2.6.31及后续版本的Linux内核里&#xff0c;安装perf非常的容易。几乎能够处理所有与性能相关的事件。什么是性能事件&#xff1f;指在处理器或者操…

测试插件maven-surefire-plugin

1. 配置 1.1 参考&#xff1a;http://maven.apache.org/surefire/maven-surefire-plugin/ 1.2 配置&#xff1a; <!-- The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. --><plugin><…