cd ~
mkdir HelloGradleGroovy
cd HelloGradleGroovy
gradle init --type java-application --dsl groovy --overwrite
Choose defaults by pressing Enter for each prompt.

The gradle init command creates a standard project layout. To view this structure in your terminal, you can use the tree command.
Run the following command in your project's root directory (HelloGradleGroovy):
tree

app/build.gradleOpen the file:
gedit app/build.gradle
Replace its contents with:
plugins {
// Apply the Java plugin for compiling Java code
id 'java'
// Apply the application plugin to add support for building an application
id 'application'
}
group = 'org.example'
version = '1.0'
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
// Define your dependencies. Use JUnit Jupiter (JUnit 5) for testing.
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
// If using parameterized tests
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
}
application {
// Define the main class for the application.
mainClass = 'org.example.App'
}
// A custom task example: printing a greeting
task hello {
doLast {
println 'Hello, Gradle!'
}
}
Dependencies are declared in the dependencies block. Gradle resolves them from the repositories configured above, like Maven Central.
Example:
dependencies{
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
// Example: Adding a test dependency
}
Gradle will download these automatically during the build process.