-
Notifications
You must be signed in to change notification settings - Fork 444
/
build.gradle
123 lines (109 loc) · 3.51 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// 重复添加同样的依赖,以保证Spellbook能够独立编译
buildscript {
ext {
dokka_version = '0.9.17'
kotlin_version = '1.3.10'
}
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.dokka-android'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}
lintOptions {
abortOnError false
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
androidTest.java.srcDirs += "src/androidTest/kotlin"
}
android.libraryVariants.all { variant ->
variant.javaCompiler.dependsOn(generateMirrorClassesList)
variant.javaCompiler.dependsOn(generateMirrorMethodsList)
variant.javaCompiler.dependsOn(generateMirrorFieldsList)
}
}
repositories {
jcenter()
google()
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.0.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
//noinspection GradleDependency
compileOnly 'de.robv.android.xposed:api:53'
compileOnly 'de.robv.android.xposed:api:53:sources'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaAndroidTask) {
outputFormat = 'javadoc'
outputDirectory = "$buildDir/dokkaJavadoc"
externalDocumentationLink {
url = new URL("https://kotlinlang.org/api/latest/jvm/stdlib/")
}
externalDocumentationLink {
url = new URL("https://developer.android.com/reference/")
}
externalDocumentationLink {
url = new URL("http://api.xposed.info/reference/")
}
}
def generateMirrorList(String type, String filename) {
def SRC_DIR = "src/main/kotlin/"
def MIRROR_DIR = "src/main/kotlin/com/gh0u1l5/wechatmagician/spellbook/mirror"
def prefixLength = file(SRC_DIR).absolutePath.length() + 1
def classes = fileTree(MIRROR_DIR).filter { file ->
file.name == "${type}.kt"
}.collect { file ->
def relativePath = file.absolutePath.drop(prefixLength)
relativePath.replaceAll('[\\\\/]', '.').substring(0, relativePath.length() - 3)
}.sort()
file("$MIRROR_DIR/${filename}.kt").text = """package com.gh0u1l5.wechatmagician.spellbook.mirror
/**
* Dynamically generated by build.gradle
*/
val $filename = listOf (
${classes.join(",\n ")}
)
"""
}
task generateMirrorClassesList() {
generateMirrorList("Classes", "MirrorClasses")
}
task generateMirrorMethodsList() {
generateMirrorList("Methods", "MirrorMethods")
}
task generateMirrorFieldsList() {
generateMirrorList("Fields", "MirrorFields")
}
apply from: 'maven.gradle'