Skip to content

Instantly share code, notes, and snippets.

@tadfisher
Created June 27, 2018 19:50
Show Gist options
  • Save tadfisher/4b87da75998e60c36c7d920a77c7af16 to your computer and use it in GitHub Desktop.
Save tadfisher/4b87da75998e60c36c7d920a77c7af16 to your computer and use it in GitHub Desktop.
Fabric Gradle plugin property investigation
class ProjectVariantState {
def COMMAND_LINE_BETA_PROPERTIES = [
"betaDistributionReleaseNotes",
"betaDistributionReleaseNotesFilePath",
"betaDistributionEmails",
"betaDistributionEmailsFilePath",
"betaDistributionGroupAliases",
"betaDistributionGroupAliasesFilePath",
"betaDistributionNotifications"
]
def ALL_BETA_PROPERTIES = COMMAND_LINE_BETA_PROPERTIES + "betaDistributionApkFilePath"
static ProjectVariantState deriveFrom(project, variant, buildType) {
`find`.call(`srcDirs`.callGetProperty(`assets`.callGetProperty(`sourceSets`.callGetProperty(`android`
return new ProjectVariantState().apply {
assetsPath = project.android.sourceSets.assets.srcDirs.find { it.exists() }
resPath = ...
jniPath = ...
...
resolveMinifyPath(buildType)
collectUploadDistributionProperties(project, variant)
collectProperty(project, variant, "alwaysUpdateBuildId")
}
}
private void collectUploadDistributionProperties(project, variant) {
ALL_BETA_PROPERTIES.each {
collectProperty(project, variant, property)
}
}
private void collectProperty(project, variant, propertyName) {
def buildType = variant.buildType
def searchLocations = variant.productFlavors + [buildType, project.android.defaultConfig]
def variantValue = searchLocations.findResult { getExtPropertyOrNull(it) }
def propertyValue = variantValue != null ? variantValue : project.getProperty(CrashlyticsPlugin.class.EXTENSION_NAME).propertyName
if (propertyValue != null) {
setProperty(propertyName, propertyValue)
}
}
}
task.doLast {
def args = ["-uploadDist", apkFilePath]
ProjectVariantState.COMMAND_LINE_BETA_PROPERTIES.each {
if (hasProperty(it)) { // this == FabricTaskBuilder
args.add("-$it", getProperty(it)
}
}
callDevtoolsWrappingRuntimeExceptions(args)
}
FabricTaskBuilder createTaskBuilder(variant, taskAffix, manifestPath, outputManifestDirectories, buildId) {
def projectState = ProjectVariantState.deriveFrom(project, variant, variant.buildType)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment