Skip to content

Commit

Permalink
Merge pull request #9709 from Stypox/reproducible-build
Browse files Browse the repository at this point in the history
Fix reproducible builds
  • Loading branch information
TobiGr committed Jan 24, 2023
2 parents b6bf0ff + a69f74f commit 444ac5f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import com.android.tools.profgen.ArtProfileKt
import com.android.tools.profgen.ArtProfileSerializer
import com.android.tools.profgen.DexFile

plugins {
id "com.android.application"
id "kotlin-android"
Expand Down Expand Up @@ -308,3 +312,24 @@ static String getGitWorkingBranch() {
return ""
}
}

project.afterEvaluate {
tasks.compileReleaseArtProfile.doLast {
outputs.files.each { file ->
if (file.toString().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, "")
}
}
}
}
}

0 comments on commit 444ac5f

Please sign in to comment.