@@ -18,7 +18,7 @@ dependencies {
18
18
testImplementation(" org.robolectric:robolectric:${version(" robolectric" )} " )
19
19
testImplementation(" org.smali:baksmali:${version(" baksmali" )} " )
20
20
21
- " r8" (" com.android.tools.build:builder:7.0 .0-alpha14 " )
21
+ " r8" (" com.android.tools.build:builder:7.1 .0-alpha01 " )
22
22
}
23
23
24
24
val optimizedDexDir = File (buildDir, " dex-optim/" )
@@ -41,24 +41,65 @@ val runR8NoOptim by tasks.registering(RunR8::class) {
41
41
dependsOn(" jar" )
42
42
}
43
43
44
- // TODO: Disable the test until we have published version of R8 that supports Kotlin 1.5.0 metadata
45
-
46
- // tasks.test {
47
- // // Ensure the R8-processed dex is built and supply its path as a property to the test.
48
- // dependsOn(runR8)
49
- // dependsOn(runR8NoOptim)
50
- //
51
- // inputs.files(optimizedDexFile, unOptimizedDexFile)
52
- //
53
- // systemProperty("dexPath", optimizedDexFile.absolutePath)
54
- // systemProperty("noOptimDexPath", unOptimizedDexFile.absolutePath)
55
- //
56
- // // Output custom metric with the size of the optimized dex
57
- // doLast {
58
- // println("##teamcity[buildStatisticValue key='optimizedDexSize' value='${optimizedDexFile.length()}']")
59
- // }
60
- // }
44
+ tasks.test {
45
+ // Ensure the R8-processed dex is built and supply its path as a property to the test.
46
+ dependsOn(runR8)
47
+ dependsOn(runR8NoOptim)
48
+
49
+ inputs.files(optimizedDexFile, unOptimizedDexFile)
50
+
51
+ systemProperty(" dexPath" , optimizedDexFile.absolutePath)
52
+ systemProperty(" noOptimDexPath" , unOptimizedDexFile.absolutePath)
53
+
54
+ // Output custom metric with the size of the optimized dex
55
+ doLast {
56
+ println (" ##teamcity[buildStatisticValue key='optimizedDexSize' value='${optimizedDexFile.length()} ']" )
57
+ }
58
+ }
61
59
62
60
externalDocumentationLink(
63
61
url = " https://developer.android.com/reference/"
64
62
)
63
+ /*
64
+ * Task used by our ui/android tests to test minification results and keep track of size of the binary.
65
+ */
66
+ open class RunR8 : JavaExec () {
67
+
68
+ @OutputDirectory
69
+ lateinit var outputDex: File
70
+
71
+ @InputFile
72
+ lateinit var inputConfig: File
73
+
74
+ @InputFile
75
+ val inputConfigCommon: File = File (" testdata/r8-test-common.pro" )
76
+
77
+ @InputFiles
78
+ val jarFile: File = project.tasks.named<Zip >(" jar" ).get().archivePath
79
+
80
+ init {
81
+ classpath = project.configurations[" r8" ]
82
+ main = " com.android.tools.r8.R8"
83
+ }
84
+
85
+ override fun exec () {
86
+ // Resolve classpath only during execution
87
+ val arguments = mutableListOf (
88
+ " --release" ,
89
+ " --no-desugaring" ,
90
+ " --min-api" , " 26" ,
91
+ " --output" , outputDex.absolutePath,
92
+ " --pg-conf" , inputConfig.absolutePath
93
+ )
94
+ arguments.addAll(project.configurations[" runtimeClasspath" ].files.map { it.absolutePath })
95
+ arguments.add(jarFile.absolutePath)
96
+
97
+ args = arguments
98
+
99
+ project.delete(outputDex)
100
+ outputDex.mkdirs()
101
+
102
+ super .exec()
103
+ }
104
+ }
105
+
0 commit comments