File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ import com.android.tools.profgen.ArtProfileKt
2+ import com.android.tools.profgen.ArtProfileSerializer
3+ import com.android.tools.profgen.DexFile
4+
15plugins {
26 id " com.android.application"
37 id " kotlin-android"
@@ -308,3 +312,24 @@ static String getGitWorkingBranch() {
308312 return " "
309313 }
310314}
315+
316+ project. afterEvaluate {
317+ tasks. compileReleaseArtProfile. doLast {
318+ outputs. files. each { file ->
319+ if (file. toString(). endsWith(" .profm" )) {
320+ println (" Sorting ${ file} ..." )
321+ def version = ArtProfileSerializer . valueOf(" METADATA_0_0_2" )
322+ def profile = ArtProfileKt.ArtProfile (file)
323+ def keys = new ArrayList (profile. profileData. keySet())
324+ def sortedData = new LinkedHashMap ()
325+ Collections . sort keys, new DexFile.Companion ()
326+ keys. each { key -> sortedData[key] = profile. profileData[key] }
327+ new FileOutputStream (file). with {
328+ write(version. magicBytes$profgen)
329+ write(version. versionBytes$profgen)
330+ version. write$profgen(it, sortedData, " " )
331+ }
332+ }
333+ }
334+ }
335+ }
You can’t perform that action at this time.
0 commit comments