forked from Kotlin/kotlinx.coroutines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
106 lines (82 loc) · 2.91 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
repositories {
google()
}
configurations {
r8
}
dependencies {
compileOnly "com.google.android:android:$android_version"
compileOnly "com.android.support:support-annotations:$android_support_version"
testImplementation "com.google.android:android:$android_version"
testImplementation "org.robolectric:robolectric:$robolectric_version"
testImplementation "org.smali:baksmali:$baksmali_version"
r8 'com.android.tools.build:builder:4.0.0-alpha06' // Contains r8-2.0.4-dev
}
class RunR8Task extends JavaExec {
@OutputDirectory
File outputDex
@InputFile
File inputConfig
@InputFile
final File inputConfigCommon = new File('testdata/r8-test-common.pro')
@InputFiles
final File jarFile = project.jar.archivePath
@Override
Task configure(Closure closure) {
super.configure(closure)
classpath = project.configurations.r8
main = 'com.android.tools.r8.R8'
return this
}
@Override
void exec() {
// Resolve classpath only during execution
def arguments = [
'--release',
'--no-desugaring',
'--output', outputDex.absolutePath,
'--pg-conf', inputConfig.absolutePath
]
arguments.addAll(project.configurations.runtimeClasspath.files.collect { it.absolutePath })
arguments.addAll(jarFile.absolutePath)
args = arguments
if (outputDex.exists()) {
outputDex.deleteDir()
}
outputDex.mkdirs()
super.exec()
}
}
def optimizedDexDir = new File(buildDir, "dex-optim/")
def unOptimizedDexDir = new File(buildDir, "dex-unoptim/")
def optimizedDexFile = new File(optimizedDexDir, "classes.dex")
def unOptimizedDexFile = new File(unOptimizedDexDir, "classes.dex")
task runR8(type: RunR8Task, dependsOn: 'jar'){
outputDex = optimizedDexDir
inputConfig = file('testdata/r8-test-rules.pro')
}
task runR8NoOptim(type: RunR8Task, dependsOn: 'jar') {
outputDex = unOptimizedDexDir
inputConfig = file('testdata/r8-test-rules-no-optim.pro')
}
test {
// Ensure the R8-processed dex is built and supply its path as a property to the test.
dependsOn(runR8)
dependsOn(runR8NoOptim)
inputs.files(optimizedDexFile, unOptimizedDexFile)
systemProperty 'dexPath', optimizedDexFile.absolutePath
systemProperty 'noOptimDexPath', unOptimizedDexFile.absolutePath
// Output custom metric with the size of the optimized dex
doLast {
println("##teamcity[buildStatisticValue key='optimizedDexSize' value='${optimizedDexFile.length()}']")
}
}
tasks.withType(dokka.getClass()) {
externalDocumentationLink {
url = new URL("https://developer.android.com/reference/")
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
}
}