Skip to content

Instantly share code, notes, and snippets.

@Maragues
Forked from jpeddicord/build.gradle
Last active December 19, 2015 15:09
Show Gist options
  • Save Maragues/5974337 to your computer and use it in GitHub Desktop.
Save Maragues/5974337 to your computer and use it in GitHub Desktop.
// additional required configuration to hook into the build script
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
// specify signing properties on the command line
if (hasProperty('storeFile')) {
println 'Generating a signed package.'
android.signingConfigs.release.storeFile = file(storeFile)
android.signingConfigs.release.storePassword = storePassword
android.signingConfigs.release.keyAlias = keyAlias
android.signingConfigs.release.keyPassword = keyPassword
} else {
android.buildTypes.release.signingConfig = null
}
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "Usage: $0 keystore"
exit 1
fi
if [[ ! -f $1 ]]; then
echo "$1 doesn't exist or isn't a keystore"
exit 1
fi
keystore=$1
read -s -p "Keystore Password: " STORE_PASS
echo
read -p "Key Alias: " KEY_ALIAS
read -s -p "Key Password: " KEY_PASS
echo
#using "$1" appended the keystore path to the project path, which didn't work for an Android Gradle project structure.
#MyProject
#--MyApp
#----my.keystore
#--gradlew
#--release.sh
#To execute it: ./release.sh MyApp/my.keystore
# remove the trailing directories from the keystore
export ORG_GRADLE_PROJECT_storeFile="${keystore#*/}"
export ORG_GRADLE_PROJECT_storePassword="$STORE_PASS"
export ORG_GRADLE_PROJECT_keyAlias="$KEY_ALIAS"
export ORG_GRADLE_PROJECT_keyPassword="$KEY_PASS"
./gradlew signingReport
read -p "Is this correct? [y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
./gradlew build
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment