-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
101 lines (91 loc) · 2.99 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
101 lines (91 loc) · 2.99 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
98
99
100
101
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessExtensionPredeclare
import com.diffplug.spotless.LineEnding
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import java.net.URI
import org.jetbrains.dokka.gradle.DokkaTaskPartial
plugins {
alias(libs.plugins.buildConfig) apply false
alias(libs.plugins.dokka)
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.kotlinSerialization) apply false
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.shadowJar) apply false
alias(libs.plugins.spotless)
}
allprojects {
apply(plugin = "com.diffplug.spotless")
val spotlessFormatters: SpotlessExtension.() -> Unit = {
lineEndings = LineEnding.PLATFORM_NATIVE
format("misc") {
target("*.md", ".gitignore")
endWithNewline()
}
kotlin {
target("src/**/*.kt")
ktfmt(libs.versions.ktfmt.get()).googleStyle()
trimTrailingWhitespace()
endWithNewline()
targetExclude("**/spotless.kt")
}
kotlinGradle {
target("*.kts")
ktfmt(libs.versions.ktfmt.get()).googleStyle()
trimTrailingWhitespace()
endWithNewline()
}
}
configure<SpotlessExtension> {
spotlessFormatters()
if (project.rootProject == project) {
predeclareDeps()
}
}
if (project.rootProject == project) {
configure<SpotlessExtensionPredeclare> { spotlessFormatters() }
}
}
subprojects {
val isPublished = project.hasProperty("POM_ARTIFACT_ID")
pluginManager.withPlugin("com.vanniktech.maven.publish") {
apply(plugin = "org.jetbrains.dokka")
tasks.withType<DokkaTaskPartial>().configureEach {
moduleName.set(project.path.removePrefix(":").replace(":", "/"))
outputDirectory.set(layout.buildDirectory.dir("docs/partial"))
dokkaSourceSets.configureEach {
val readMeProvider = project.layout.projectDirectory.file("README.md")
if (readMeProvider.asFile.exists()) {
includes.from(readMeProvider)
}
if (name.contains("androidTest", ignoreCase = true)) {
suppress.set(true)
}
skipDeprecated.set(true)
// Skip internal packages
perPackageOption {
// language=RegExp
matchingRegex.set(".*\\.internal\\..*")
suppress.set(true)
}
// AndroidX and Android docs are automatically added by the Dokka plugin.
// Add source links
sourceLink {
localDirectory.set(layout.projectDirectory.dir("src").asFile)
val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
remoteUrl.set(
providers.gradleProperty("POM_SCM_URL").map { scmUrl ->
URI("$scmUrl/tree/main/$relPath/src").toURL()
}
)
remoteLineSuffix.set("#L")
}
}
}
configure<MavenPublishBaseExtension> {
publishToMavenCentral(automaticRelease = isPublished)
if (isPublished) {
signAllPublications()
}
}
}
}