From a19638c3e334454c23dbc93bb7945f6d2ace00de Mon Sep 17 00:00:00 2001 From: cyBerta Date: Tue, 14 Nov 2017 15:47:37 +0100 Subject: recompile native code for ProductionBeta and ProductionRelease builds --- app/build.gradle | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 60ae394f..cdeccb6c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,6 @@ +import java.util.regex.Matcher +import java.util.regex.Pattern + apply plugin: 'com.android.application' android { @@ -233,4 +236,37 @@ task buildNative ( type: Exec ) { commandLine 'sh', 'misc/build-native.sh', 'USE_BREAKPAD=0', '-j 8' } +task cleanNative( type: Delete ) { + def shouldClean = getCurrentFlavorForBetaOrRelease() == "production" + println "cleanNative: " + shouldClean + + if (shouldClean) { + def dirName = "obj" + file( dirName ).list().each{ + f -> delete "${dirName}/${f}" + } + } +} + +def getCurrentFlavorForBetaOrRelease() { + Gradle gradle = getGradle() + String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() + + Pattern pattern; + + if( tskReqStr.contains( "assemble" ) ) + pattern = Pattern.compile("assemble(\\w+)(Beta|Release)") + else + pattern = Pattern.compile("generate(\\w+)(Beta|Release)") + + Matcher matcher = pattern.matcher( tskReqStr ) + + if( matcher.find() ) + return matcher.group(1).toLowerCase() + else + { + return ""; + } +} + preBuild.dependsOn buildNative -- cgit v1.2.3