forked from Gh0u1L5/WechatSpellbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
132 lines (115 loc) · 3.63 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
124
125
126
127
128
129
130
131
132
// 重复添加同样的依赖,以保证Spellbook能够独立编译
buildscript {
ext {
dokka_version = '0.9.17'
kotlin_version = '1.2.41'
}
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
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'
kotlin {
experimental {
coroutines "enable"
}
}
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//noinspection GradleDependency
compileOnly 'de.robv.android.xposed:api:53'
compileOnly 'de.robv.android.xposed:api:53:sources'
implementation 'net.dongliu:apk-parser:2.5.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.21'
}
dokka {
externalDocumentationLink {
url = new URL("http://api.xposed.info/reference/")
}
}
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaAndroidTask) {
outputFormat = 'javadoc'
outputDirectory = "$buildDir/dokkaJavadoc"
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'