How to create a new gradle project?
Pre-requisites:
- Java
- Gradle
Steps
- Create a folder using command
- mkdir myproject
- Go inside the folder
- cd myproject
- Run command
- gradle init
- Select type as application
- Select language as java
- Select build script as Kotlin
- Select Unit Test Framework as Junit Jupiter
Different files in gradle project
- settings.gradle.kts
- This is used to define the repositories under
- dependencyResolutionManagement
- pluginManagement
- This is used set the project name and include sub projects
- rootProject.name={Name of the project}
- include("app") Name of all the subprojects to be included
- build.gradle.sts
- This is the build script for particular project
- It has below sections
- plugins - We can add different type of plugins
- e.g core plugins
plugins {
- repositories: Add repositories
- dependencies: Add dependencies
- application: Set the main class for the project
- tasks: Create a gradle task e.g. copy task would be like