Last active
January 18, 2023 13:58
-
-
Save obfusk/a5463fe404e22d6691f180279266b94a to your computer and use it in GitHub Desktop.
-> https://github.com/obfusk/reproducible-apk-tools#gradle-integration | reproducible-apk-tools gradle integration
This file contains hidden or 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
| // NB: assumes reproducible-apk-tools is a submodule in the app repo's | |
| // root dir; adjust the path accordingly if it is found elsewhere | |
| project.afterEvaluate { | |
| tasks.compileReleaseArtProfile.doLast { | |
| outputs.files.each { file -> | |
| if (file.toString().endsWith(".profm")) { | |
| exec { | |
| commandLine( | |
| "../reproducible-apk-tools/inplace-fix.py", | |
| "sort-baseline", file | |
| ) | |
| } | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or 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
| // NB: assumes reproducible-apk-tools is a submodule in the app repo's | |
| // root dir; adjust the path accordingly if it is found elsewhere | |
| android { | |
| applicationVariants.all { variant -> | |
| variant.outputs.each { output -> | |
| variant.packageApplicationProvider.get().doLast { | |
| def tools = "${android.sdkDirectory}/build-tools/${android.buildToolsVersion}" | |
| exec { | |
| // set PATH for zipalign | |
| environment "PATH", "${tools}:$System.env.PATH" | |
| commandLine( | |
| "../reproducible-apk-tools/inplace-fix.py", | |
| "--zipalign", "fix-newlines", output.outputFile, | |
| "META-INF/services/*" | |
| ) | |
| } | |
| // re-sign w/ apksigner if needed | |
| if (variant.signingConfig != null) { | |
| def sc = variant.signingConfig | |
| exec { | |
| environment "KS_PASS", sc.storePassword | |
| environment "KEY_PASS", sc.keyPassword | |
| commandLine( | |
| "${tools}/apksigner", "sign", "-v", | |
| "--ks", sc.storeFile, | |
| "--ks-pass", "env:KS_PASS", | |
| "--ks-key-alias", sc.keyAlias, | |
| "--key-pass", "env:KEY_PASS", | |
| output.outputFile | |
| ) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment