An open API service indexing awesome lists of open source software.

https://github.com/getrighhttt/gradlethings

Repository to demonstrate how to work with Gradle.
https://github.com/getrighhttt/gradlethings

Last synced: 5 months ago
JSON representation

Repository to demonstrate how to work with Gradle.

Awesome Lists containing this project

README

          

# Gradle

### What is Gradle?
- Build automation tool
- Takes your code and packages it into deployable unit
- applies to small or large projects
- written in the Kotlin language
- can also be written in Groovy
- highly configurable to meet project needs

![image](https://github.com/GetRighhttt/GradleThings/assets/105057858/80ea3be1-8068-42ca-86cf-06d37943f191)

#### Why use Gradle
- Makes building and running applications very easy
- no need for people using your projects to install Gradle
- Gradle wrapper comes bundled in with project
- Just run `./graldew build` and you should be ok
- Very concise; no XML configuration needed
- lightning fast
- Had **dependency management** which is an automated technique for declaring and resolving external resources needed for the project

#### Key Gradle Concepts
- `build.gradle.kts` is the Gradle build script file
- defines how project is build
- written in Kotlin DSL
- lives in top-level of the project
- has `plugins` (extend gradle capability), `repositories`, and `dependencies`, also houses some metadata
- `tasks` defines a unit of work
- invoked form the command line
- `./gradlew build` is considered a build task
- see a full list of available tasks by running `./gradlew tasks`
- can also create own custom tasks
- task can have dependencies on other tasks
- creates a task graph of dependencies
- `wrapper` is the script used to invoke Gradle and run tasks
- always committed into version control
- no local Gradle installation required for anyone building your project
- contains a specific version of gradle for the project
- ALWAYS use the Gradle wrapper script for safety (unless initializing new gradle project)

#### Gradle Project Structure
- Gradle supports single-project and multi-project structures
- single-project structures are usually for smaller projects with a single build output
- multi-project structures are for larger projects with multiple build outputs

#### Typical Structure
| -- `build.gradle.kts` -> main build configuration file
| -- `gradle` -> contains configuration and code for Gradle wrapper
| -- `wrapper`
| | -- `gradle-wrapper.jar`
| -- `gradle-wrapper.properties`
| -- `gradlew` -> gradle wrapper script (Windows and Linux)
| -- `gradlew.bat`
-- `settings.gradle.kts` -> set project name, and additional settings
- all files and directories should be committed into version control automatically
- `.gradle` should not be committed into version control as it is hidden
- project specific cache used internally by Gradle
- `.gitignore` automatically generated by gradle when a project is created

#### Gradle Wrapper
- Standardizes a gradle version used for the project
- Recommended way to invoke all Gradle builds and scripts
- Ensures reliable and standardized build for gradle