Skip to content

Instantly share code, notes, and snippets.

@rockerhieu
Last active June 22, 2019 20:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rockerhieu/eaf7cfd6265cbcc73084 to your computer and use it in GitHub Desktop.
Save rockerhieu/eaf7cfd6265cbcc73084 to your computer and use it in GitHub Desktop.
Integrate Corona with Gradle
android.applicationVariants.all { variant ->
def variantBuildTypeName = variant.name.capitalize()
def buildType = variant.buildType.name.toString()
def output = null
project.("pre" + variantBuildTypeName + "Build") {
println "Corona: compiling..."
output = "${projectDir}/compile_corona.sh ${CORONA_ENTERPRISE_PATH} ${projectDir} ${buildType}".execute()
println "${output.getInputStream().text}"
println "Corona: compiled!"
}
project.("package" + variantBuildTypeName).doLast {
def outputFileUnsigned = variant.outputFile.absolutePath
def outputFileSignedUnaligned = variant.outputFile.absolutePath.replaceAll("-unsigned", "-unaligned")
def outputFileSignedAligned = variant.outputFile.absolutePath.replaceAll("-unsigned", "")
output = "cp ${variant.outputFile.absolutePath} ${outputFileSignedUnaligned}".execute()
println "${output.getInputStream().text}"
println "Corona: verifying apk..."
println "${projectDir}/verify_corona.sh ${CORONA_ENTERPRISE_PATH} ${outputFileSignedUnaligned} ${buildType}"
output = "${projectDir}/verify_corona.sh ${CORONA_ENTERPRISE_PATH} ${outputFileSignedUnaligned} ${buildType}".execute()
println "${output.getInputStream().text}"
println "Corona: verified!"
if (buildType.equals("debug")) {
println "Corona: signing apk for ${variantBuildTypeName}..."
output = "jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ${projectDir}/keystores/debug.keystore -storepass android ${outputFileSignedUnaligned} androiddebugkey".execute()
println "${output.getInputStream().text}"
println "Corona: apk for ${variantBuildTypeName} is signed"
} else {
println "Corona: signing apk for ${variantBuildTypeName}..."
output = "jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ${RELEASE_STORE_FILE} -storepass ${RELEASE_STORE_PASSWORD} ${outputFileSignedUnaligned} ${RELEASE_KEY_ALIAS}".execute()
println "${output.getInputStream().text}"
println "Corona: apk for ${variantBuildTypeName} is signed"
}
output = "${ANDROID_HOME}/tools/zipalign -v -f 4 ${outputFileSignedUnaligned} ${outputFileSignedAligned}".execute()
println "${output.getInputStream().text}"
variant.outputFile = new File(outputFileSignedAligned)
"mv ${outputFileUnsigned} ${outputFileUnsigned}.original".execute()
"cp ${outputFileSignedAligned} ${outputFileUnsigned}".execute()
}
}
export LUA_CPATH=$1/Corona/mac/bin/?.so
export TARGET_PLATFORM=android
export PROJECT_DIR=$2
export CORONA_COPY_PNG_PRESERVE=--preserve
export CONFIGURATION=$3
export CORONA_ASSETS_DIR=$2/../Corona
export CORONA_TARGET_RESOURCES_DIR=$2/src/$3/assets
export CORONA_TARGET_EXECUTABLE_DIR=$2/src/$3/assets
$1/Corona/mac/bin/lua \
-e \
"package.path='/Applications/CoronaEnterprise/Corona/shared/bin/?.lua;/Applications/CoronaEnterprise/Corona/shared/bin/?/init.lua;'..package.path" \
$1/Corona/shared/bin/Compile.lua \
mac \
$1
export CORONA_APK_PATH=$2
export CORONA_RESOURCE_CAR_PATH=./src/$3/assets
$1/Corona/mac/bin/CertifyBuild.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment