-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
99 lines (90 loc) · 3.37 KB
/
Copy pathbuild.gradle
File metadata and controls
99 lines (90 loc) · 3.37 KB
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
plugins {
id 'com.android.library' version libs.versions.agp apply false
id 'org.jetbrains.kotlin.android' version libs.versions.kotlin apply false
id 'base'
}
tasks.register("collectAars", Copy) {
from(subprojects.collect { subproject ->
subproject.layout.buildDirectory.dir("outputs/aar")
})
include("*.aar")
into(layout.buildDirectory.dir("outputs/aar"))
outputs.dir(layout.buildDirectory.dir("outputs/aar"))
}
tasks.register("collectLibs", Copy) {
from(subprojects.collect { subproject ->
subproject.layout.buildDirectory.dir("libs/")
})
include("*.jar")
into(layout.buildDirectory.dir("libs/"))
outputs.dir(layout.buildDirectory.dir("libs/"))
}
tasks.register("collectLibLicenses", Copy) {
from(subprojects.collect { subproject ->
subproject.layout.buildDirectory.dir("licenses/")
})
into(layout.buildDirectory.dir("licenses/"))
outputs.dir(layout.buildDirectory.dir("licenses/"))
}
tasks.named("clean", Delete) {
delete(
// This refetches all the AARs from the subprojects
layout.buildDirectory.dir("outputs/aar"),
layout.buildDirectory.dir("libs"),
layout.buildDirectory.dir("licenses"),
// This regenerates all AARs in the subprojects
// Increases build time by about 15 seconds
// Comment it out if you want
subprojects.collectMany { subproject ->
[
subproject.layout.buildDirectory.dir("outputs/aar"),
subproject.layout.buildDirectory.dir("libs")
]
}
)
}
tasks.named("collectAars") {
dependsOn(tasks.named("collectLibs"))
dependsOn(tasks.named("collectLibLicenses"))
}
subprojects { subproject ->
afterEvaluate {
// Makes sure collectAars only does release and debug
tasks.configureEach { task ->
if (task.name.startsWith("bundle") &&
!task.name.endsWith("ReleaseAar") &&
!task.name.endsWith("DebugAar")) {
task.enabled = false
logger.lifecycle("Disabled task: ${task.name}")
}
}
// Makes sure AARs are collected from subprojects at the right time
tasks.matching { it.name in ["assembleRelease", "assembleDebug"] }.configureEach {
finalizedBy(rootProject.tasks.named("collectAars"))
}
// Makes sure AARs are deleted from subprojects at the right time
tasks.matching { ["bundleReleaseAar", "bundleDebugAar"].any {
prefix -> it.name.startsWith(prefix)
} }.configureEach {
mustRunAfter(rootProject.tasks.named("clean"))
}
tasks.matching { ["buildNdkBuildRelease", "buildNdkBuildDebug"].any {
prefix -> it.name.startsWith(prefix)
} }.configureEach {
finalizedBy(rootProject.tasks.named("clean"))
}
// Makes sure JARs are put in top level build folder on build
tasks.matching { it.name == 'jar' }.configureEach {
finalizedBy(rootProject.tasks.named('collectLibs'))
finalizedBy(rootProject.tasks.named('collectLibLicenses'))
}
// Force SDK21 on all of them!!
if (subproject.plugins.hasPlugin('com.android.library')) {
subproject.android {
defaultConfig {
minSdkVersion 21
}
}
}
}
}