Gradle
- Build and dependency management
- default for Android and Kotlin projects
- It supports two languages:
groovyandkotlin - dependency:
- specific library/artifact found in a remote repository such as Maven Central or Google Maven
- dependency configuration:
- grouping of dependencies. Common examples include
implementationandtestImplementation, both made available by the Java plugin. - By default Gradle doesn’t come with any dependency configurations.
- grouping of dependencies. Common examples include
groupis same asgroupIdin mavenmoduleis same asartifactIdin maven
Files
build.gradleservice/build.gradlesettings.gradlegradle.properties
Gradle Wrapper
- Gradle Wrapper has scripts that can be run on OS:
gradlew.sh—*nixOSsgradlew.bat— Windows
- Can be used to install different versions of gradle and define the gradle version for the project
Important Commands
gradle tasks # lists all tasks
gradle -q dependencies # lists all dependencies
gradle build -x test # ignore running test while building Plugins
- Java Plugin
plugins {
id 'java'
}- Spring boot plugin
plugins {
id 'org.springframework.boot' version '3.2.3'
}- Android plugin
plugins {
id 'com.android.application' version '8.2.2' apply false
id 'com.android.library' version '8.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
}Java plugin
- It is one of the core plugin: https://docs.gradle.org/current/userguide/plugin_reference.html#plugin_reference
- Supported Tasks:
- compileJava
- compileTestJava: depends on
classes - classes
- testClasses
- test: depends on
testClasses - clean
- Dependency between tasks:

- Source sets:
- main
- test
- Dependency Configurations:
implementationcompileOnlyruntimeOnlyetc.
- Dependency configs relationship
- green: dep. config: we can declare own dependencies
- grey: dep. config: can’t declare own dependencies. used only by task
- cyan: task
- main sourceset:

- test sourceset:
