mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-05 05:19:49 +02:00
Merge Reproducible Builds
This commit makes release builds reproducible. This will help folks update the app from F-Droid when it's released there.
This commit is contained in:
@@ -98,6 +98,30 @@ android {
|
||||
doNotStrip '**/*.so'
|
||||
}
|
||||
namespace 'eu.toldi.infinityforlemmy'
|
||||
|
||||
|
||||
task rearrangeClass(type: Exec) {
|
||||
commandLine 'python', '../scripts/fixEventBus.py'
|
||||
}
|
||||
|
||||
applicationVariants.all { variant ->
|
||||
if (variant.name == 'release') {
|
||||
task("compileSingleFile${variant.name.capitalize()}", type: JavaCompile, dependsOn: rearrangeClass) {
|
||||
def filePath = project.rootDir.absolutePath + '/app/build/generated/ap_generated_sources/release/out/eu/toldi/infinityforlemmy/'
|
||||
source = files(filePath)
|
||||
includes = ["**/EventBusIndex.java"]
|
||||
classpath = variant.getCompileClasspath() + files(project.rootDir.absolutePath + '/app/build/intermediates/javac/release/classes')
|
||||
destinationDir = file("$buildDir/intermediates/javac/release/classes")
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).all { task ->
|
||||
if (task.name == 'compileReleaseJavaWithJavac') {
|
||||
task.finalizedBy "compileSingleFile${variant.name.capitalize()}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -246,3 +270,34 @@ dependencies {
|
||||
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:x.y'
|
||||
}
|
||||
|
||||
// NB: Android Studio can't find the imports; this does not affect the
|
||||
// actual build since Gradle can find them just fine.
|
||||
|
||||
import com.android.tools.profgen.ArtProfileKt
|
||||
import com.android.tools.profgen.ArtProfileSerializer
|
||||
import com.android.tools.profgen.DexFile
|
||||
|
||||
project.afterEvaluate {
|
||||
tasks.each { task ->
|
||||
if (task.name.startsWith("compile") && task.name.endsWith("ReleaseArtProfile")) {
|
||||
task.doLast {
|
||||
outputs.files.each { file ->
|
||||
if (file.name.endsWith(".profm")) {
|
||||
println("Sorting ${file} ...")
|
||||
def version = ArtProfileSerializer.valueOf("METADATA_0_0_2")
|
||||
def profile = ArtProfileKt.ArtProfile(file)
|
||||
def keys = new ArrayList(profile.profileData.keySet())
|
||||
def sortedData = new LinkedHashMap()
|
||||
Collections.sort keys, new DexFile.Companion()
|
||||
keys.each { key -> sortedData[key] = profile.profileData[key] }
|
||||
new FileOutputStream(file).with {
|
||||
write(version.magicBytes$profgen)
|
||||
write(version.versionBytes$profgen)
|
||||
version.write$profgen(it, sortedData, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user