相关文件位于“tutorial/step12-maven/files/mouse-gestures ”目录下:
文件名 | 说明 |
---|---|
build.gradle | 构建文件样例 |
allatori.xml | 典型的配置文件 |
按照下面的步骤在Android Studio中进行配置:
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}"))
}