Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
| 4 | |
| 5 | import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink |
| 6 | import org.jetbrains.dokka.gradle.DokkaTask |
| 7 | import java.net.URL |
| 8 | |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 9 | configurations { |
| 10 | create("r8") |
| 11 | } |
| 12 | |
| 13 | dependencies { |
| 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 Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 24 | val optimizedDexDir = File(buildDir, "dex-optim/") |
| 25 | val unOptimizedDexDir = File(buildDir, "dex-unoptim/") |
| 26 | |
| 27 | val optimizedDexFile = File(optimizedDexDir, "classes.dex") |
| 28 | val unOptimizedDexFile = File(unOptimizedDexDir, "classes.dex") |
| 29 | |
Victor Turansky | 964cd92 | 2020-05-02 19:52:56 +0300 | [diff] [blame] | 30 | val runR8 by tasks.registering(RunR8::class) { |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 31 | outputDex = optimizedDexDir |
| 32 | inputConfig = file("testdata/r8-test-rules.pro") |
| 33 | |
| 34 | dependsOn("jar") |
| 35 | } |
| 36 | |
Victor Turansky | 964cd92 | 2020-05-02 19:52:56 +0300 | [diff] [blame] | 37 | val runR8NoOptim by tasks.registering(RunR8::class) { |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 38 | outputDex = unOptimizedDexDir |
| 39 | inputConfig = file("testdata/r8-test-rules-no-optim.pro") |
| 40 | |
| 41 | dependsOn("jar") |
| 42 | } |
| 43 | |
| 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 | } |
| 59 | |
Victor Turansky | 964cd92 | 2020-05-02 19:52:56 +0300 | [diff] [blame] | 60 | externalDocumentationLink( |
| 61 | url = "https://developer.android.com/reference/" |
| 62 | ) |