---
# System prepended metadata

title: Context View

---

# Context View
## Table of Contents
| Section |
|--|
| [Introduction](#Introduction) <br>- [Gradle vs Scripts](#Gradle-vs-Scripts) <br>- [Gradle vs Maven](#Gradle-vs-Maven) <br>- [Summary](#Summary)|
| [Context Model](#Context-Model) <br>- [External Entities](#External-Entities) <br>- [Interactions](#Interactions) |


## Introduction

Gradle is a build automation tool written in Java and runs on the Java Virtual Machine. Within the context of software development, building refers to the process of converting source code into executables (and other artifacts). 

Gradle offers a set of [configuration script files](https://hackmd.io/pxTuGPrNQi2Am2p5z5U8Jw#Data-Source) which can be configured to dictate build behavior. These files may define tasks, which are executable pieces of code. They can further apply plugins which can add more tasks or modify a project's configuration at run-time.

Plugins are a direct consequence of both Gradle's [architectural principle #1](https://hackmd.io/fn2LiZ9VSba1y9bW7DXf5w#1) and its [flexibility concerns](https://hackmd.io/bWYLQjmpRiCjD_okjztzfA).

As evidenced by plugins, Gradle follows a [microkernel architectural style](https://hackmd.io/wlbMQxXaSmuTBk5hLWpKDQ#Microkernel-Architectural-Style). On the other hand, tasks are derived from the [command design pattern](https://hackmd.io/wlbMQxXaSmuTBk5hLWpKDQ#Command-Design-Pattern).

### Gradle vs Scripts

While it is possible for developers to write their own script files to build their projects, such simple scripts are often rigid and lacking in features. A change in the project's structure may require the scripts to be completely rewritten. 

Writing scripts to automate the building process of complex software is a time consuming endeavor. On the other hand, configuring Gradle to build complex software is simpler and less time consuming.

Gradle allows developers to save time by "sharing code" via plugins. It also has the ability to download  missing dependencies, run automated tests or even custom tasks.

### Gradle vs Maven

Maven is another build automation tool and is Gradle's main competitor. Gradle is architectured to be both faster and more flexible than Maven. 

Maven uses a simple and easy to grasp language, XML, to define its build configuration. Gradle uses Java-like languages, Groovy and Kotlin, to define its build configuration. This allows Gradle to be more flexible than Maven.

It outperforms Maven thanks to the combination of the [gradle daemon](https://hackmd.io/dGIiC6_sRrqdVqo3gRFUmQ#Gradle-Daemon), [incremental builds](https://hackmd.io/wlbMQxXaSmuTBk5hLWpKDQ?both#Incremental-Builds) and the [build cache](https://hackmd.io/pxTuGPrNQi2Am2p5z5U8Jw#Build-Cache).

### Summary

Gradle is a build automation tool that:
* Is more convenient to use than custom build scripts for complex software
* Is faster and more flexible than Maven
* Can download missing dependencies and run a multitide of custom tasks.

## Context Model

![Context Model](https://i.imgur.com/JotGi0q.jpg)


### External Entities

|Entity|Description|
|--|--|
|Project Developers| These are Gradle's typical users. They are software developers tasked with writing the software entity depicted in the model. Their main interaction with Gradle would be the execution of a build task.|
|Plugin Developers|These are Gradle users or Gradle developers who are usually more familiar with Gradle. They extend Gradle's functionality by writing plugins and making them publicly available.|
|Repository| Refers to (usually remote) storage which **facilitates** the download and upload of software packages. Examples include [GitHub](https://github.com/), [Maven Repository](https://mvnrepository.com/), and [Gradle Plugin Repository](https://plugins.gradle.org/).|
|Software|This is the software Gradle is tasked with building. It may be comprised of a single or multiple projects. This respresents the software's source code and other artifacts relevant to the building process. The software is written by the Project Developers. |


### Interactions
#### Project Developers

Project developers mainly run build tasks. Upon execution, this task typically automatically downloads missing dependencies, compiles the code, runs tests, etc...

For the build task to exhibit the desired build behavior project developers would have to first setup the build automation process. To do this, they would add the appropriate plugins and tasks to each project's [build script file](https://hackmd.io/pxTuGPrNQi2Am2p5z5U8Jw#Data-Source). They would also configure Gradle's general settings and properties.

Once the automation setup is complete, they usually make small configuration changes such as modifying the value of a property in the [gradle.properties](https://hackmd.io/pxTuGPrNQi2Am2p5z5U8Jw#Data-Source) file(s) or modfiying a project's configuration. The difference between these configuration changes and the changes made during the automation setup is simply their scale.

#### Plugin Developers

Plugin developers write Java/Kotlin/Groovy classes and make them publicly available. These plugins are used to extend Gradle's functionality. Plugin developers upload their class/plugin to a repository such as GitHub and register their plugin to [Gradle's plugin repository](https://plugins.gradle.org/) which is used for indexing (e.g. plugin name -> GitHub url).

Project developers may want to apply a plugin to a project. To do this, they simply include the plugin name under the [project's configuration script file](https://hackmd.io/pxTuGPrNQi2Am2p5z5U8Jw#buildgradle). Gradle defines a resolution process to download the plugin from the appropriate source (e.g. Github).

More information on Plugins can be found in the [functional view](https://hackmd.io/dGIiC6_sRrqdVqo3gRFUmQ#ConfigurationExecution-Element-Catalog) and [information view](https://hackmd.io/pxTuGPrNQi2Am2p5z5U8Jw#class-file).

#### Repository

Repositories contain information relevant to the build process, this could be missing project dependencies, missing plugins or simply a url (e.g. the Gradle Plugin Repository is used to index plugin names to the urls where they can be found).

#### Software

Refers to the software being developed by the Project Developers. The software may follow a single-project or multi-project structure. Gradle enables each project to be built, compiled, tested, etc... Project Developers can specify the build behavior for each project in the project's build configuration file.
