Last active
September 12, 2022 13:33
-
-
Save hkkcngz/9860a537e32ee50c5c5f5e25d54ebdff to your computer and use it in GitHub Desktop.
Allatori, build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
... | |
// for applications | |
applicationVariants.all { variant -> | |
variant.javaCompileProvider.get().doLast { | |
runAllatori(variant) | |
} | |
} | |
// for libraries | |
// libraryVariants.all { variant -> | |
// variant.javaCompileProvider.get().doLast { | |
// runAllatori(variant) | |
// } | |
// } | |
} | |
def runAllatori(variant) { | |
copy { | |
from "$projectDir/allatori.xml" | |
into "$buildDir/intermediates/classes/" | |
expand(classesRoot: variant.javaCompileProvider.get().destinationDir, | |
kotlinRoot: "${buildDir}/tmp/kotlin-classes/${variant.name}", | |
androidJar: "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar", | |
classpathJars: variant.javaCompileProvider.get().classpath.getAsPath(), | |
logFile: "allatori-log-${variant.name}.xml") | |
rename('allatori.xml', "allatori-${variant.name}.xml") | |
} | |
new File("${variant.javaCompileProvider.get().destinationDir}-obfuscated").deleteDir() | |
javaexec { | |
main = 'com.allatori.Obfuscate' | |
classpath = files("$rootDir/allatori/allatori.jar") | |
args "$buildDir/intermediates/classes/allatori-${variant.name}.xml" | |
} | |
new File("${variant.javaCompileProvider.get().destinationDir}").deleteDir() | |
new File("${variant.javaCompileProvider.get().destinationDir}-obfuscated").renameTo(new File("${variant.javaCompileProvider.get().destinationDir}")) | |
// Kotlin support | |
// new File("${buildDir}/tmp/kotlin-classes/${variant.name}").deleteDir() | |
// new File("${buildDir}/tmp/kotlin-classes/${variant.name}-obfuscated").renameTo(new File("${buildDir}/tmp/kotlin-classes/${variant.name}")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task runAllatoriOnRelease() { | |
Gradle gradle = getGradle() | |
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() | |
boolean isDebuggable = android.buildTypes.release.debuggable | |
if (tskReqStr.contains("Release") && isDebuggable) { | |
// Allatori Codes | |
android.libraryVariants.all { variant -> | |
variant.javaCompileProvider.get().doLast { | |
runAllatori(variant) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment