Skip to content

Commit ce37412

Browse files
committed
~ Report the size of optimized Android Dex as teamcity metric
1 parent 830438d commit ce37412

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

ui/kotlinx-coroutines-android/build.gradle

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
repositories {
@@ -66,30 +66,36 @@ class RunR8Task extends JavaExec {
6666
}
6767
}
6868

69-
def optimizedDex = new File(buildDir, "dex-optim/")
70-
def unOptimizedDex = new File(buildDir, "dex-unoptim/")
69+
def optimizedDexDir = new File(buildDir, "dex-optim/")
70+
def unOptimizedDexDir = new File(buildDir, "dex-unoptim/")
71+
72+
def optimizedDexFile = new File(optimizedDexDir, "classes.dex")
73+
def unOptimizedDexFile = new File(unOptimizedDexDir, "classes.dex")
7174

7275
task runR8(type: RunR8Task, dependsOn: 'jar'){
73-
outputDex = optimizedDex
76+
outputDex = optimizedDexDir
7477
inputConfig = file('testdata/r8-test-rules.pro')
7578
}
7679

7780
task runR8NoOptim(type: RunR8Task, dependsOn: 'jar'){
78-
outputDex = unOptimizedDex
81+
outputDex = unOptimizedDexDir
7982
inputConfig = file('testdata/r8-test-rules-no-optim.pro')
8083
}
8184

8285
test {
8386
// Ensure the R8-processed dex is built and supply its path as a property to the test.
8487
dependsOn(runR8)
8588
dependsOn(runR8NoOptim)
86-
def dex1 = new File(optimizedDex, "classes.dex")
87-
def dex2 = new File(unOptimizedDex, "classes.dex")
8889

89-
inputs.files(dex1, dex2)
90+
inputs.files(optimizedDexFile, unOptimizedDexFile)
91+
92+
systemProperty 'dexPath', optimizedDexFile.absolutePath
93+
systemProperty 'noOptimDexPath', unOptimizedDexFile.absolutePath
9094

91-
systemProperty 'dexPath', dex1.absolutePath
92-
systemProperty 'noOptimDexPath', dex2.absolutePath
95+
// Output custom metric with the size of the optimized dex
96+
doLast {
97+
println("##teamcity[buildStatisticValue key='optimizedDexSize' value='${optimizedDexFile.length()}']")
98+
}
9399
}
94100

95101
tasks.withType(dokka.getClass()) {

0 commit comments

Comments
 (0)