-
Notifications
You must be signed in to change notification settings - Fork 94
/
build.gradle.kts
103 lines (97 loc) · 3.73 KB
/
build.gradle.kts
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
import com.diffplug.gradle.spotless.SpotlessPlugin
import com.android.build.gradle.LibraryPlugin
plugins {
id(libs.versions.gradlePlugins.maven.publish.get())
alias(libs.plugins.android).apply(false)
alias(libs.plugins.library).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.kotlinJvm).apply(false)
alias(libs.plugins.ksp).apply(false)
alias(libs.plugins.test).apply(false)
alias(libs.plugins.spotless).apply(false)
alias(libs.plugins.compose.compiler).apply(false)
alias(libs.plugins.dokka)
}
val Project.composeMetricsDir get() = layout.buildDirectory.asFile.get().absolutePath + "/compose_metrics"
val Project.composeReportsDir get() = layout.buildDirectory.asFile.get().absolutePath + "/compose_reports"
tasks.register("cleanComposeMetrics") {
group = "Cleaning"
description = "Clean compose metrics folders"
subprojects.forEach {
if (
it.pluginManager.hasPlugin(libs.plugins.convention.compose.library.get().pluginId)
||
it.pluginManager.hasPlugin(libs.plugins.convention.compose.app.get().pluginId)
) {
val dir = File(it.composeMetricsDir)
if (dir.exists()) {
dir.also { file ->
println("Deleting compose metrics >>> ${file.path} <<<")
}.deleteRecursively()
}
}
}
}
tasks.register("cleanComposeReports") {
group = "Cleaning"
description = "Clean compose reports folders"
subprojects.forEach {
if (
it.pluginManager.hasPlugin(libs.plugins.convention.compose.library.get().pluginId)
||
it.pluginManager.hasPlugin(libs.plugins.convention.compose.app.get().pluginId)
) {
val dir = File(it.composeReportsDir)
if (dir.exists()) {
dir.also { file ->
println("Deleting compose reports >>> ${file.path} <<<")
}.deleteRecursively()
}
}
}
}
allprojects {
plugins.matching { anyPlugin -> anyPlugin is SpotlessPlugin }
.whenPluginAdded {
extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude("${layout.buildDirectory.asFile.get()}/**/*.kt")
ktlint()
.setEditorConfigPath("${project.rootDir}/spotless/.editorconfig")
}
}
}
}
subprojects {
plugins.matching { anyPlugin -> supportedPlugins(anyPlugin) }.whenPluginAdded {
val artifactName = if (parent?.name == "KAHelpers") name else "${parent?.name ?: ""}-$name"
apply(plugin = libs.versions.gradlePlugins.maven.publish.get())
plugins.withType<JavaLibraryPlugin> {
publishing.publications {
create<MavenPublication>("kotlin") {
artifactId = artifactName
version = libs.versions.app.version.versionName.get()
afterEvaluate {
from(components["kotlin"])
}
}
}
}
plugins.withType<LibraryPlugin> {
afterEvaluate {
publishing.publications {
create<MavenPublication>("release") {
artifactId = artifactName
version = libs.versions.app.version.versionName.get()
afterEvaluate {
from(components["release"])
}
}
}
}
}
}
}
fun supportedPlugins(anyPlugin: Plugin<*>?) =
anyPlugin is LibraryPlugin || anyPlugin is JavaLibraryPlugin