blob: 4f247883598f6c201ca7fc2d9830571434665231 [file] [log] [blame]
Vsevolod Tolstopyatov0f158122020-04-29 23:35:41 +03001/*
2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
6import org.jetbrains.dokka.gradle.DokkaTask
7import java.net.URL
8
Vsevolod Tolstopyatov0f158122020-04-29 23:35:41 +03009configurations {
10 create("r8")
11}
12
13dependencies {
14 compileOnly("com.google.android:android:${version("android")}")
15 compileOnly("androidx.annotation:annotation:${version("androidx_annotation")}")
16
17 testImplementation("com.google.android:android:${version("android")}")
18 testImplementation("org.robolectric:robolectric:${version("robolectric")}")
19 testImplementation("org.smali:baksmali:${version("baksmali")}")
20
21 "r8"("com.android.tools.build:builder:4.0.0-alpha06") // Contains r8-2.0.4-dev
22}
23
Vsevolod Tolstopyatov0f158122020-04-29 23:35:41 +030024val optimizedDexDir = File(buildDir, "dex-optim/")
25val unOptimizedDexDir = File(buildDir, "dex-unoptim/")
26
27val optimizedDexFile = File(optimizedDexDir, "classes.dex")
28val unOptimizedDexFile = File(unOptimizedDexDir, "classes.dex")
29
Victor Turansky964cd922020-05-02 19:52:56 +030030val runR8 by tasks.registering(RunR8::class) {
Vsevolod Tolstopyatov0f158122020-04-29 23:35:41 +030031 outputDex = optimizedDexDir
32 inputConfig = file("testdata/r8-test-rules.pro")
33
34 dependsOn("jar")
35}
36
Victor Turansky964cd922020-05-02 19:52:56 +030037val runR8NoOptim by tasks.registering(RunR8::class) {
Vsevolod Tolstopyatov0f158122020-04-29 23:35:41 +030038 outputDex = unOptimizedDexDir
39 inputConfig = file("testdata/r8-test-rules-no-optim.pro")
40
41 dependsOn("jar")
42}
43
44tasks.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}
59
Victor Turansky964cd922020-05-02 19:52:56 +030060externalDocumentationLink(
61 url = "https://developer.android.com/reference/"
62)