A Gradle plugin that lets a local gradle.local.properties file override the values in gradle.properties.
Developers often need different property values on their own machine, such as a local repository URL, a feature flag or a credential.
Editing the shared gradle.properties risks committing those values by accident.
With this plugin you keep the overrides in gradle.local.properties and leave the shared file untouched.
-
Properties in
gradle.local.propertiesreplace the project properties of the same name. -
Properties that don’t exist yet are added.
-
A warning is logged whenever the file is found and contains properties, so overrides are never silent.
Apply the plugin to the project that contains (or should read) gradle.local.properties.
plugins {
id("org.infosmid.plugins.local-properties") version "1.0.3"
}Declare the plugin in the catalog:
[versions]
local-properties = "1.0.3"
[plugins]
infosmid-local-properties = { id = "org.infosmid.plugins.local-properties", version.ref = "local-properties" }Then reference it through the generated libs accessor.
build.gradle)plugins {
alias(libs.plugins.infosmid.local.properties)
}build.gradle.kts)plugins {
alias(libs.plugins.infosmid.local.properties)
}|
Note
|
The plugin is applied per project. In a multi-project build, apply it in each project that has its own gradle.local.properties.
|
See the Gradle Plugin Portal page for other versions.
Create a file named gradle.local.properties in the project directory.
# gradle.local.properties
myRepoUrl=http://localhost:8081/repository/maven-public
featureX=trueIdeally add this file to .gitignore so it is never committed:
gradle.local.propertiesBuild scripts read the values as usual:
repositories {
maven { url = findProperty('myRepoUrl') ?: 'https://repo.maven.apache.org/maven2' }
}repositories {
maven(url = findProperty("myRepoUrl") as String? ?: "https://repo.maven.apache.org/maven2")
}| Message | Meaning |
|---|---|
|
The file exists and has at least one property (warning). |
|
An existing property was overridden. |
|
The property only exists in |
Released under the MIT License.