0% found this document useful (0 votes)
9 views

Gradle Fun

Gradle is a versatile build automation tool that simplifies the process of building and managing software projects, utilizing a Groovy-based DSL for defining build scripts. It supports dependency management, task execution, and plugin integration, making it suitable for both small and large projects. The Gradle wrapper allows for easy project setup and ensures compatibility across different environments by managing Gradle versions.

Uploaded by

sharanreddy169
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Gradle Fun

Gradle is a versatile build automation tool that simplifies the process of building and managing software projects, utilizing a Groovy-based DSL for defining build scripts. It supports dependency management, task execution, and plugin integration, making it suitable for both small and large projects. The Gradle wrapper allows for easy project setup and ensures compatibility across different environments by managing Gradle versions.

Uploaded by

sharanreddy169
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

GRADLE

SNEHA G
A S S T. P R O F
DEPT OF CSE
DR AIT
WHAT IS GRADLE??
 Gradle is a general-purpose build automation tool
 Takes your code & packages it  Deployable Unit

 Applies to small / Large project  written in Kotlin / Gravy


 It comes with rich build DOMAIN-SPECIFIC language (DSL) based on
Groovy [ instead of XML]
 It support “build-by-convention” approach [ on – demand convention]
 But it is very flexible and extensible
 It derives all the best and integrates well with Ivy, Ant and Maven
GRADLE BUILD TOOL
WHY WOULD YOU USE
GRADLE??
 Gradle makes building & running applications very easy
Gradle is a powerful, flexible and widely used build automation tool
primarily employed in software development
 Gradle excels at resolving and managing project dependencies,
streamlining the process of incorporating external libraries.
 Gradle's Groovy-based DSL provides a concise and expressive way to
define build scripts, making them easier to read and maintain.
 Gradle wrapper comes bundled with project
WHAT ARE THE KEY GRADLE
CONCEPT??
 Concept includes  projects, build scripts, dependency management, tasks, and
plugins
 A Gradle project can be a single application or library, or a multi-project build with
a root project and subprojects.
 These scripts, written in Groovy or Kotlin, instruct Gradle on how to build the
project, including compiling code, running tests, and packaging binaries.
 Gradle automatically resolves and manages dependencies, which are external
resources needed by the project, like libraries or frameworks.
 Tasks are the building blocks of the build process, representing individual units of
work like compiling code, running tests, or generating documentation.
 Plugins extend Gradle's functionality by adding new tasks, features, or
configurations to the build process.
GRADLE CONCEPTS : TASKS
 Define a unit of work
 Invoked from the command line

> gradlew build

 See available task by running


> gradle task
 Can create your own custom tasks
 Tasks have dependencies on other tasks
GRADLE CONCEPTS : TASKS
 Creates a task graph
BUILD

Check  test  which test the


Which packages ASSEMBLE TASK CHECK TASK final key Gradle concept is the
the application wrapper

Gradle provides several built-in tasks  clean, build [ compiling


code] and check [ running test]
GRADLE CONCEPTS : WRAPPER
 The Wrapper is a script that invokes a
declared version of Gradle, downloading it
beforehand if necessary
 As a result, developers can get up and
running with a Gradle project quickly without
having to follow the manual for installation
processes saving company time and money
Gradle executes the build process that is
independent of the installed version. So, the
wrapper is the preferred way for starting a
Gradle build. We can create the wrapper
script according to our needs.
GRADLE CONCEPTS : WRAPPER
 Script used to invoke Gradle & run tasks
• gradlew file for UNIX based system
• gradlew.bat for Windows systems
Always committed into version control
 No local Gradle installation required for anyone building your project.
Contains a specific version of Gradle for your project
 Gradle Wrappers are used to  avoid any incompatibility problems  Project build works
with the specified versions
Always use Gradle wrapper
Initialising a new Gradle Project

> gradle init


GRADLE CONCEPTS :
INTRODUCTION
 Gradle is a modern, customizable build automation
 Gradle build script  written in Kotlin / Groovy
 Build script contained in
Build.gradle.kts file

 It contains plugins, metadata, repositories and dependencies.


 Tasks represent a unit of work & are linked through the task graph
 Run tasks using the Gradle wrapper  checked into version control
Gradle - 1. Build Script
 Gradle builds a script file for handling two things; one
is projects and other is tasks. Every Gradle build represents one or
more projects.
 A project represents a library JAR or a web application or it might
represent a ZIP that is assembled from the JARs produced by other
projects. In simple words, a project is made up of different tasks.
 A task means a piece of work, which a build performs. A task might
be compiling some classes, creating a JAR, generating Javadoc, or
publishing some archives to a repository. [ Task  adding behavior
and properties to task]
 Gradle uses Groovy language for writing scripts.
Gradle – 2. Managing Plugins
There’re two types of plugins in Gradle – script and binary.
To benefit from additional functionality, every plugin needs to
go through two phases: resolving and applying.
Resolving means finding the correct version of the plugin jar
and adding that to the class path of the project.
Applying plugins is executing Plugin.apply(T) on the project.
3. Dependency Management
Gradle supports a very flexible dependency management system, it’s compatible with
the wide variety of available approaches.
Best practices for dependency management in Gradle are versioning, dynamic
versioning, resolving version conflicts, and managing transitive dependencies.

A. Dependency Configuration  Dependencies are grouped into different configurations. A


configuration has a name and they can extend each other.
• Declaring dependencies in various configurations: 
implementation, testImplementation, and runtimeOnly in various formats.

B. Declaring Dependencies  Spring and Hibernate using several different ways


GRADLE SETUP
 Check Java is installed or not
 Download  Gradle software as Zip files & extract it.
 Set path  Gradle  Environment Variables
 Check Gradle Version

$ gradle -v
GRADLE SETUP
GRADLE SETUP
GRADLE SETUP
GRADLE SETUP
ADVANTAGES

You might also like