To configure gradle, use groovy’s DSL.

DSL stands for Domain Specific Language. Instead of using a rigid format like XML (where you describe data), you use a simplified, real-world programming language to configure the project.

It’s the “layer” that Gradle puts on top of Groovy so you can write things like implementation ‘org.slf4j:slf4j-api:1.7.21’ instead of complex Java function calls.


This is the most practical way to manage confidential information or configurations that have specific machine specifications and no shared information in the code repository.

Add these lines there:

# Personal Credentials (Outside the project)
repoUser=my_nexus_username
repoPassword=my_secret_password_123

Because it’s outside the project folder, it’s not uploaded to Git, making it ideal for passwords.


read it in the build.gradle

Gradle automatically loads the properties of this file and makes them available to the project object.

for example:

publishing {
repositories {
maven {
// The destination is public, it comes from the YAML
url = yamlConfig.publishing.repo_url
credentials {
// We look for the property. If it doesn't exist in gradle.properties,
// we can fail or use a default value.
username = project.findProperty('repoUser') ?: "guest"
password = project.findProperty('repoPassword') ?: ""
}
}
}
}

security gradle.properties is High (only on your machine)

The structure of gradle.properties is Flat (Key=Value)