Convert Gradle gradle.properties to JSON
Transform Gradle build configuration from gradle.properties into JSON format for analysis, documentation, or CI/CD integration.
Detailed Explanation
Gradle Properties
Gradle uses gradle.properties for project-wide build configuration. Unlike Spring Boot properties, Gradle properties are typically flat (no dot-notation nesting for object hierarchy) and control JVM settings, feature flags, versioning, and plugin configuration.
Example gradle.properties
# JVM Configuration
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.daemon=true
# Android Configuration
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=true
# Version Management
VERSION_NAME=2.1.0
VERSION_CODE=42
GROUP=com.example.myapp
POM_ARTIFACT_ID=my-library
# Signing
RELEASE_STORE_FILE=release-key.jks
RELEASE_KEY_ALIAS=my-key-alias
Flat vs Nested JSON
For Gradle properties, the flat mode is usually more appropriate since keys like org.gradle.jvmargs represent a single configuration key, not a nested object path. Using flat mode produces:
{
"org.gradle.jvmargs": "-Xmx2048m -Dfile.encoding=UTF-8",
"org.gradle.parallel": "true",
"VERSION_NAME": "2.1.0"
}
However, using nested mode can group related settings together:
{
"org": {
"gradle": {
"jvmargs": "-Xmx2048m -Dfile.encoding=UTF-8",
"parallel": true
}
},
"android": {
"useAndroidX": true,
"enableJetifier": true
}
}
Choose the mode that best matches your use case: flat for fidelity, nested for structure.
Use Case
Documenting Gradle build configuration, integrating build settings into CI/CD pipeline configuration (GitHub Actions, Jenkins), or comparing gradle.properties across multiple projects or modules.