I have a project with multiple modules, some are android libraries some are android apps, i see a lot of code in the build.gradle file is duplicated, especially for example the release part and key configuration is always the same.
One strategy is to include always a file like “apply from: releases.gradle” on every single module, but i think its a bit ugly especially because i need to write relative paths like “…/…/buildFiles/release.gradle”
Is there any better approach for this? Can i create a plugin that will insert basic releases inside the Android Block? If so, is there an example on how to do that? So a plugin that will generate this:
android {
buildTypes {
release {
// Will not remove unused resources by default
shrinkResources false
// Run proguard
minifyEnabled true
proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile '../assets/build/proguard-project.txt'
// Sign
signingConfig signingConfigs.release
// Fallback for tasks
matchingFallbacks = ['release']
}
// Public, Signed, Beta
beta.initWith(buildTypes.release)
beta {
versionNameSuffix "beta"
// Fallback for tasks
matchingFallbacks = ['beta', 'release']
}
// Internal Release
debug {
versionNameSuffix "dbg"
signingConfig signingConfigs.debug
// Fallback for tasks
matchingFallbacks = ['debug', 'beta', 'release']
}
}
}