-
Notifications
You must be signed in to change notification settings - Fork 49
/
android-metalava.gradle
99 lines (87 loc) · 3.88 KB
/
android-metalava.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
//import com.android.build.gradle.api.BaseVariant
//import com.android.build.gradle.api.LibraryVariant
configurations {
metalava
}
dependencies {
// Metalava isn't released yet. Check in its jar and explicitly track its transitive deps.
metalava(rootProject.files("metalava.jar"))
metalava("com.android.tools.external.org-jetbrains:uast:27.2.0-alpha11")
metalava("com.android.tools.external.com-intellij:kotlin-compiler:27.2.0-alpha11")
metalava("com.android.tools.external.com-intellij:intellij-core:27.2.0-alpha11")
metalava("com.android.tools.lint:lint-api:27.2.0-alpha11")
metalava("com.android.tools.lint:lint-checks:27.2.0-alpha11")
metalava("com.android.tools.lint:lint-gradle:27.2.0-alpha11")
metalava("com.android.tools.lint:lint:27.2.0-alpha11")
metalava("com.android.tools:common:27.2.0-alpha11")
metalava("com.android.tools:sdk-common:27.2.0-alpha11")
metalava("com.android.tools:sdklib:27.2.0-alpha11")
metalava("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.30")
metalava("org.jetbrains.kotlin:kotlin-reflect:1.4.30")
metalava("org.ow2.asm:asm:8.0")
metalava("org.ow2.asm:asm-tree:8.0")
}
android.libraryVariants.all { /*LibraryVariant*/ variant ->
if (variant.buildType.isDebuggable()) {
return
}
tasks.register("updateApi", JavaExec) {
inputs.dir('src/main/java')
outputs.file('api/current.txt')
classpath = configurations.metalava
main = 'com.android.tools.metalava.Driver'
dependsOn variant.assembleProvider
doFirst {
args = [
'--no-banner',
'--source-path', 'src/main/java',
'--compatible-output=no',
'--omit-common-packages=yes',
'--output-kotlin-nulls=yes',
'--hide', 'HiddenSuperclass',
'--hide', 'DeprecationMismatch',
'--classpath', variant.getCompileClasspath(null).join(";") +
";${android.sdkDirectory}\\platforms\\android-${android.compileSdk}\\android.jar",
// '--sdk-home', android.sdkDirectory,
// '--compile-sdk-version', android.compileSdk,
'--api', 'api/current.txt'
]
}
}
def checkApi = tasks.register("checkApi", JavaExec) {
inputs.file('api/current.txt')
inputs.dir('src/main/java')
outputs.file('api/current.txt')
classpath = configurations.metalava
main = 'com.android.tools.metalava.Driver'
dependsOn variant.assembleProvider
doFirst {
args = [
'--no-banner',
'--source-path', 'src/main/java',
'--compatible-output=no',
'--omit-common-packages=yes',
'--output-kotlin-nulls=yes',
'--input-kotlin-nulls=yes',
'--hide', 'HiddenSuperclass',
'--hide', 'DeprecationMismatch',
'--hide', 'AddedPackage',
'--hide', 'AddedClass',
'--hide', 'AddedMethod',
'--hide', 'AddedFinalUninstantiable',
// '--hide', 'ChangedDeprecated',
// '--hide', 'ChangedAbstract',
// '--hide', 'ChangedValue',
// '--hide', 'InvalidNullConversion', //@ParametersAreNonNullByDefault is unsupported.
'--classpath', variant.getCompileClasspath(null).join(";") +
";${android.sdkDirectory}\\platforms\\android-${android.compileSdk}\\android.jar",
// '--sdk-home', android.sdkDirectory,
// '--compile-sdk-version', 'android-29',
'--check-compatibility', 'api/current.txt'
]
}
}
tasks.named("check").configure {
dependsOn checkApi
}
}