-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
163 lines (149 loc) · 6.01 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
@file:Suppress("UnstableApiUsage")
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.SonatypeHost
import dev.iurysouza.modulegraph.LinkText
import dev.iurysouza.modulegraph.Orientation
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.configurationcache.extensions.capitalized
plugins {
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.android.application).apply(false)
alias(libs.plugins.android.library).apply(false)
alias(libs.plugins.jetbrains.compose).apply(false)
alias(libs.plugins.kotlin.multiplatform).apply(false)
alias(libs.plugins.kotlin.cocoapods).apply(false)
alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
alias(libs.plugins.adamko.dokkatoo.html)
alias(libs.plugins.arturbosch.detekt).apply(false)
alias(libs.plugins.vanniktech.mavenPublish).apply(false)
alias(libs.plugins.iurysouza.modulegraph)
}
allprojects {
group = "com.revenuecat.purchases"
version = rootProject.libs.versions.revenuecat.kmp.get()
plugins.withType<MavenPublishPlugin> {
configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.DEFAULT, automaticRelease = true)
signAllPublications()
// We override the artifact ID of :revenuecatui for consistency with the other SDKs. We
// could not name our Gradle module :ui, because this somehow conflicts with compose.ui
// in the iosMain source set. We can retry this at a later time.
val artifactIdSuffix = when (project.name) {
"revenuecatui" -> "ui"
else -> project.name
}
coordinates(
groupId = group.toString(),
artifactId = "purchases-kmp-$artifactIdSuffix",
version = version.toString()
)
pom {
name.set("purchases-kmp-(${project.name})")
description.set("Mobile subscriptions in hours, not months.")
inceptionYear.set("2024")
url.set("https://github.com/RevenueCat/purchases-kmp")
licenses {
license {
name.set("The MIT License (MIT)")
url.set("http://opensource.org/licenses/MIT")
distribution.set("repo")
}
}
developers {
developer {
id.set("revenuecat")
name.set("RevenueCat, Inc.")
url.set("https://www.revenuecat.com/")
}
}
scm {
url.set("https://github.com/RevenueCat/purchases-kmp")
connection.set("scm:git:git://github.com/RevenueCat/purchases-kmp.git")
developerConnection.set("scm:git:ssh://[email protected]/RevenueCat/purchases-kmp.git")
}
}
}
// Register a Detekt task for all published modules.
with(this@allprojects) {
projectDir
.resolve("src")
.listFiles { child -> child.isDirectory }
.orEmpty()
.also { sourceDirectories ->
tasks.registerDetektTask(
taskName = "detektAll",
taskDescription = "Runs Detekt on all source sets.",
reportName = "all",
sourceDirs = files(sourceDirectories)
)
sourceDirectories.forEach { sourceDir ->
val sourceSet = sourceDir.name
tasks.registerDetektTask(
taskName = "detekt${sourceSet.capitalized()}",
taskDescription = "Runs Detekt on the $sourceSet source set.",
reportName = "$name${sourceSet.capitalized()}",
sourceDirs = files(sourceDir)
)
}
}
}
}
}
apiValidation {
ignoredProjects.addAll(listOf("apiTester", "composeApp", "mappings"))
@OptIn(kotlinx.validation.ExperimentalBCVApi::class)
klib {
enabled = true
}
}
dependencies {
dokkatoo(projects.core)
dokkatoo(projects.datetime)
dokkatoo(projects.either)
dokkatoo(projects.models)
dokkatoo(projects.result)
dokkatoo(projects.revenuecatui)
}
moduleGraphConfig {
fun Dependency.readmePath() = "./$name/README.md"
fun Dependency.heading() = "## :${name} module dependency graph"
val topToBottom = Orientation.TOP_TO_BOTTOM
// Intentional root for all modules, so we always show the entire graph.
val rootModuleRegex = ".*revenuecatui.*"
listOf(
projects.core,
projects.mappings,
projects.models,
projects.revenuecatui,
).forEach { project ->
// All graphs are equal, but we need to specify 1 main graph. So :core it is.
if (project == projects.core) {
readmePath.set(project.readmePath())
heading = project.heading()
orientation.set(topToBottom)
rootModulesRegex.set(rootModuleRegex)
} else graph(
readmePath = project.readmePath(),
heading = project.heading(),
) {
orientation = topToBottom
rootModulesRegex = rootModuleRegex
}
}
}
private fun TaskContainer.registerDetektTask(
taskName: String,
taskDescription: String,
reportName: String,
sourceDirs: ConfigurableFileCollection,
) =
register<Detekt>(taskName) {
description = taskDescription
setSource(sourceDirs.map { it.resolve("kotlin") })
config = files("$rootDir/config/detekt/detekt.yml")
reports {
html.outputLocation = file("build/reports/detekt/$reportName.html")
xml.outputLocation = file("build/reports/detekt/$reportName.xml")
}
}