-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
296 lines (257 loc) · 8.64 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import com.diffplug.spotless.LineEnding
import com.vanniktech.maven.publish.SonatypeHost
import dev.teogor.winds.api.ArtifactIdFormat
import dev.teogor.winds.api.License
import dev.teogor.winds.api.NameFormat
import dev.teogor.winds.api.Person
import dev.teogor.winds.api.Scm
import dev.teogor.winds.api.TicketSystem
import dev.teogor.winds.api.Winds
import dev.teogor.winds.api.model.DependencyType
import dev.teogor.winds.ktx.person
import dev.teogor.winds.ktx.scm
import dev.teogor.winds.ktx.ticketSystem
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.dokka.gradle.DokkaPlugin
buildscript {
repositories {
google()
mavenCentral()
}
}
// Lists all plugins used throughout the project without applying them.
plugins {
alias(libs.plugins.jetbrains.kotlin.jvm) apply false
alias(libs.plugins.jetbrains.kotlin.serialization) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.firebase.crashlytics) apply false
alias(libs.plugins.firebase.perf) apply false
alias(libs.plugins.gms) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.querent) apply false
alias(libs.plugins.teogor.winds) apply true
alias(libs.plugins.about.libraries) apply false
alias(libs.plugins.vanniktech.maven) apply true
alias(libs.plugins.jetbrains.dokka) apply true
alias(libs.plugins.spotless) apply true
alias(libs.plugins.jetbrains.binary.compatibility.validator) apply true
alias(libs.plugins.ben.manes.versions) apply true
alias(libs.plugins.littlerobots.version.catalog.update) apply true
}
winds {
windsFeatures {
mavenPublishing = true
docsGenerator = true
workflowSynthesizer = true
}
moduleMetadata {
name = "Ceres"
description = """
|Ceres is a comprehensive Android development framework designed to streamline your app development process. Powered by the latest technologies like Jetpack Compose, Hilt, Coroutines, and Flow, Ceres empowers developers to build modern and efficient Android applications.
""".trimMargin()
yearCreated = 2022
websiteUrl = "https://source.teogor.dev/ceres/"
apiDocsUrl = "https://source.teogor.dev/ceres/html/"
artifactDescriptor {
group = "dev.teogor.ceres"
name = "ceres"
nameFormat = NameFormat.FULL
artifactIdFormat = ArtifactIdFormat.MODULE_NAME_ONLY
}
// Providing SCM (Source Control Management)
scm<Scm.GitHub> {
owner = "teogor"
repository = "ceres"
}
// Providing Ticket System
ticketSystem<TicketSystem.GitHub> {
owner = "teogor"
repository = "ceres"
}
// Providing Licenses
licensedUnder(License.Apache2())
// Providing Persons
person<Person.DeveloperContributor> {
id = "teogor"
name = "Teodor Grigor"
email = "open-source@teogor.dev"
url = "https://teogor.dev"
roles = listOf("Code Owner", "Developer", "Designer", "Maintainer")
timezone = "UTC+2"
organization = "Teogor"
organizationUrl = "https://github.com/teogor"
}
}
publishingOptions {
publish = false
enablePublicationSigning = true
optInForVanniktechPlugin = true
cascadePublish = true
sonatypeHost = SonatypeHost.S01
}
documentationBuilder {
htmlPath = "html/"
markdownNewlineSeparator = " "
dependencyGatheringType = DependencyType.NONE
}
}
val ktlintVersion = "0.50.0"
val excludedProjects = listOf(
project.name,
"app",
)
// Spotless
subprojects {
if (!excludedProjects.contains(this.name)) {
apply<com.diffplug.gradle.spotless.SpotlessPlugin>()
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
lineEndings = LineEnding.UNIX
kotlin {
target("**/*.kt")
targetExclude("**/build/**/*.kt")
ktlint(ktlintVersion)
.editorConfigOverride(
mapOf(
"android" to "true",
"ktlint_code_style" to "intellij_idea",
"ij_kotlin_allow_trailing_comma" to "true",
// These rules were introduced in ktlint 0.46.0 and should not be
// enabled without further discussion. They are disabled for now.
// See: https://github.com/pinterest/ktlint/releases/tag/0.46.0
"disabled_rules" to
"filename," +
"annotation,annotation-spacing," +
"argument-list-wrapping," +
"double-colon-spacing," +
"enum-entry-name-case," +
"multiline-if-else," +
"no-empty-first-line-in-method-block," +
"package-name," +
"trailing-comma," +
"spacing-around-angle-brackets," +
"spacing-between-declarations-with-annotations," +
"spacing-between-declarations-with-comments," +
"unary-op-spacing," +
"no-trailing-spaces," +
"no-wildcard-imports," +
"max-line-length",
),
)
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
trimTrailingWhitespace()
endWithNewline()
}
format("kts") {
target("**/*.kts")
targetExclude("**/build/**/*.kts")
// Look for the first line that doesn't have a block comment (assumed to be the license)
licenseHeaderFile(rootProject.file("spotless/copyright.kts"), "(^(?![\\/ ]\\*).*$)")
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/**/*.xml")
// Look for the first XML tag that isn't a comment (<!--) or the xml declaration (<?xml)
licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])")
}
}
}
}
// API Validation
apiValidation {
/**
* Packages that are excluded from public API dumps even if they
* contain public API.
*/
ignoredPackages.add("androidx.databinding")
/**
* Sub-projects that are excluded from API validation
*/
ignoredProjects.addAll(excludedProjects)
/**
* Flag to programmatically disable compatibility validator
*/
validationDisabled = false
}
// Dokka
subprojects {
if (!excludedProjects.contains(project.name)) {
afterEvaluate {
val winds: Winds by extensions
val moduleMetadata = winds.moduleMetadata
apply<DokkaPlugin>()
tasks.withType<DokkaMultiModuleTask>().configureEach {
failOnWarning.set(false)
suppressInheritedMembers.set(true)
moduleName.set(moduleMetadata.name)
moduleVersion.set(moduleMetadata.artifactDescriptor?.version.toString())
val paths = project.path.split(":")
val pathRef = paths.joinToString(separator = "/")
outputDirectory.set(rootProject.projectDir.resolve("build/reference/${pathRef}"))
}
}
}
}
tasks.dokkaHtmlMultiModule {
childProjects.values.map {
it.name
}.filter {
it != "app" && it != "bom"
}.forEach {
val taskPath = ":${it}:dokkaHtmlMultiModule"
dependsOn(taskPath)
}
}
childProjects.values.filter {
it.name != "app" && it.name != "bom"
}.forEach { subproject ->
val name = subproject.name[0].uppercaseChar() + subproject.name.substring(1)
tasks.register("publish${name}Module") {
group = "publishing"
description = "Publishes artifacts from the specified subproject."
subproject.subprojects.forEach { sp ->
sp.tasks.findByName("publish")?.let { task ->
dependsOn(task)
}
}
}
}
abstract class PublishModuleTask : DefaultTask() {
@get:Input
abstract val moduleName: Property<String>
private val childProjects = project.childProjects.values.filter {
it.name != "app" && it.name != "bom"
}
@TaskAction
fun publish() {
println("Published module: ${moduleName.get()}")
}
fun configureDependencies() {
childProjects.firstOrNull {
it.name == moduleName.get()
}?.let { subproject ->
// Handle scenarios where subproject might have subprojects (nested modules)
subproject.subprojects.forEach { childProject ->
childProject.tasks.findByName("publish")?.let { childPublishTask ->
dependsOn(childPublishTask) // Depend on child publish tasks
}
}
}
}
}
tasks.register("publishModule", PublishModuleTask::class) {
group = "publishing"
description = "Publishes artifacts from a specified module."
moduleName = project.findProperty("moduleName") as String? ?: ""
configureDependencies()
}
versionCatalogUpdate {
keep {
// keep versions without any library or plugin reference
keepUnusedVersions = true
// keep all libraries that aren't used in the project
keepUnusedLibraries = true
// keep all plugins that aren't used in the project
keepUnusedPlugins = true
}
}