-
Notifications
You must be signed in to change notification settings - Fork 312
/
Copy pathbuild.gradle
67 lines (57 loc) · 1.6 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
import javax.inject.Inject
// SPDX-License-Identifier: GPL-3.0-or-later
plugins {
id('com.android.library')
}
android {
namespace 'io.github.muntashirakon.AppManager.docs'
compileSdk compile_sdk
buildToolsVersion = build_tools
defaultConfig {
minSdk min_sdk
targetSdk target_sdk
}
compileOptions {
encoding "UTF-8"
}
}
// https://docs.gradle.org/current/userguide/service_injection.html#execoperations
interface InjectedExecOps {
@Inject
ExecOperations getExecOps()
}
tasks.register('buildDocs') {
def injected = project.objects.newInstance(InjectedExecOps)
doLast {
println("=== docs: start ===")
String buildExec = "${rootProject.projectDir.absolutePath}/scripts/make_docs.sh"
injected.execOps.exec {
workingDir = project.rootDir
executable = buildExec
}
println("=== docs: finish ===")
}
}
tasks.register('cleanupDocs') {
doLast {
File file = new File("${rootProject.projectDir.absolutePath}/docs/src/main/res")
if (file.exists()) {
deleteDir(file)
}
}
}
def deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list()
if (children == null) return false
for (String child : children) {
boolean success = deleteDir(new File(dir, child))
if (!success) return false
}
return dir.delete()
} else if (dir != null && dir.isFile()) {
return dir.delete()
} else return false
}
preBuild.dependsOn buildDocs
clean.dependsOn cleanupDocs