Android Gradle

android{

signingConfigs {
debug {
// def getDebugKeyStore = { ->
// //ls ~/.android/debug.keystore
// return “ls $System.env.HOME/.android/debug.keystore”.execute().text.trim()
// }
// storeFile file(getDebugKeyStore())
storeFile file(“../debug.keystore”)
storePassword ‘android’
keyAlias ‘AndroidDebugKey’
keyPassword ‘android’
}
}

}

/**
* @author Naval
* if no bundle is found it will create the ‘bundleAMGTestDebug’ bundle by default
* otherwise or first build type folder selected as dependent task
* so it will create the respective bundle and then creates the apks
* */
def getFirstBundle() {
def selectedBuildVariantFlavor = “bundleFlavorTestDebug”
def str= “ls $buildDir/outputs/bundle/”.execute().text
if (!str.isEmpty()) {
str = str.split(“\\n”)[0]
selectedBuildVariantFlavor = str
str = “ls $buildDir/outputs/bundle/$str”.execute().text
if (!str.isEmpty() ) {
str = str.split(“:”)[0].trim()
if (!str.isEmpty()) {
println “$str bundle found in $selectedBuildVariantFlavor”
return
}
}
println “$str bundle not found”
bundleToApk.dependsOn “bundle$selectedBuildVariantFlavor”
println “dependent task of $selectedBuildVariantFlavor”
}
else
{
println “$str : bundle folder not found or its empty”
bundleToApk.dependsOn “$selectedBuildVariantFlavor”
println “dependent task of $selectedBuildVariantFlavor”
}
}
/**
* @author Naval
* uncomment the dependsOn and give your own bundle build type
* so it will create the respective bundle and then create the apks
* */
task bundleToApk(type: Exec/*, dependsOn: ‘bundleFlavorTestDebug’*/){
println ‘bundleToApk task start’
getFirstBundle()
workingDir ‘../BundleToApks’
println ‘bundleToApk commandLine task start’
commandLine ‘./bundle2apks.command’ //working
println ‘bundleToApk commandLine task end’
// executable ‘./bundle2apks.command’ //working
doFirst {
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
println ‘bundleToApk doFirst task end’
}
doLast {
println ‘bundleToApk task end.’
}
}
//build.dependsOn bundleToApk //use this it fast