Use environment variables and external configuration mechanisms instead of hard-coding values in build scripts. This makes your build system more flexible, maintainable, and adaptable to different environments.

Why it matters:

How to implement:

  1. Replace hard-coded paths with environment variable lookups
  2. Use properties files or command-line parameters for configurable values
  3. Document configuration requirements clearly

Example: Instead of:

// Hard-coded paths that limit where ccache can be installed
val ccachePaths = listOf("/usr/bin/ccache", "/usr/local/bin/ccache")

Better approach:

// Use environment variables with fallbacks
val ccachePath = System.getenv("CCACHE_PATH") 
    ?: listOf("/usr/bin/ccache", "/usr/local/bin/ccache").firstOrNull { file(it).exists() }

if (ccachePath != null) {
    arguments("-DANDROID_CCACHE=$ccachePath")
}

Similarly, for dependency exclusions, use a consistent pattern:

configurations {
    getByName("implementation") {
        exclude(group = "commons-logging", module = "commons-logging")
        exclude(group = "commons-collections", module = "commons-collections")
    }
}