失效链接处理 |
gradle guide PDF 下载
本站整理下载:
相关截图:
主要内容:
What is Gradle?
Overview
Gradle is an open-source build automation tool that is designed to be flexible enough to build
almost any type of software. The following is a high-level overview of some of its most important
features:
High performance
Gradle avoids unnecessary work by only running the tasks that need to run because their inputs
or outputs have changed. You can also use a build cache to enable the reuse of task outputs from
previous runs or even from a different machine (with a shared build cache).
There are many other optimizations that Gradle implements and the development team
continually work to improve Gradle’s performance.
JVM foundation
Gradle runs on the JVM and you must have a Java Development Kit (JDK) installed to use it. This
is a bonus for users familiar with the Java platform as you can use the standard Java APIs in
your build logic, such as custom task types and plugins. It also makes it easy to run Gradle on
different platforms.
Note that Gradle isn’t limited to building just JVM projects, and it even comes packaged with
support for building native projects.
Conventions
Gradle takes a leaf out of Maven’s book and makes common types of projects — such as Java
projects — easy to build by implementing conventions. Apply the appropriate plugins and you
can easily end up with slim build scripts for many projects. But these conventions don’t limit
you: Gradle allows you to override them, add your own tasks, and make many other
customizations to your convention-based builds.
Extensibility
You can readily extend Gradle to provide your own task types or even build model. See the
Android build support for an example of this: it adds many new build concepts such as flavors
and build types.
IDE support
Several major IDEs allow you to import Gradle builds and interact with them: Android Studio,
IntelliJ IDEA, Eclipse, and NetBeans. Gradle also has support for generating the solution files
required to load a project into Visual Studio.
Insight
Build scans provide extensive information about a build run that you can use to identify build
issues. They are particularly good at helping you to identify problems with a build’s
performance. You can also share build scans with others, which is particularly useful if you need
to ask for advice in fixing an issue with the build.
Five things you need to know about Gradle
Gradle is a flexible and powerful build tool that can easily feel intimidating when you first start.
However, understanding the following core principles will make Gradle much more approachable
and you will become adept with the tool before you know it.
1. Gradle is a general-purpose build tool
Gradle allows you to build any software, because it makes few assumptions about what you’re
trying to build or how it should be done. The most notable restriction is that dependency
management currently only supports Maven- and Ivy-compatible repositories and the filesystem.
This doesn’t mean you have to do a lot of work to create a build. Gradle makes it easy to build
common types of project — say Java libraries — by adding a layer of conventions and prebuilt
functionality through plugins. You can even create and publish custom plugins to encapsulate your
own conventions and build functionality.
2. The core model is based on tasks
Gradle models its builds as Directed Acyclic Graphs (DAGs) of tasks (units of work). What this
means is that a build essentially configures a set of tasks and wires them together — based on their
dependencies — to create that DAG. Once the task graph has been created, Gradle determines
which tasks need to be run in which order and then proceeds to execute them.
This diagram shows two example task graphs, one abstract and the other concrete, with the
dependencies between the tasks represented as arrows:
|