-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
199 lines (179 loc) · 6.35 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
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import nl.littlerobots.vcu.plugin.versionCatalogUpdate
import nl.littlerobots.vcu.plugin.versionSelector
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradleSubplugin
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeFeatureFlag.Companion.OptimizeNonSkippingGroups
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.gradleDoctor)
alias(libs.plugins.version.catalog.update)
alias(libs.plugins.dokka)
alias(libs.plugins.dependencyAnalysis)
alias(libs.plugins.atomicfu)
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.serialization) apply false
// plugins already on a classpath (conventions)
// alias(libs.plugins.androidApplication) apply false
// alias(libs.plugins.androidLibrary) apply false
// alias(libs.plugins.kotlinMultiplatform) apply false
}
buildscript {
dependencies {
classpath(libs.android.gradle)
classpath(libs.kotlin.gradle)
classpath(libs.detekt.gradle)
}
}
allprojects {
group = Config.artifactId
version = Config.versionName
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(Config.jvmTarget)
freeCompilerArgs.addAll(Config.jvmCompilerArgs)
optIn.addAll(Config.optIns)
}
}
}
atomicfu {
dependenciesVersion = rootProject.libs.versions.kotlinx.atomicfu.get()
transformJvm = false
jvmVariant = "VH"
transformJs = false
}
subprojects {
apply(plugin = rootProject.libs.plugins.dokka.id)
dependencies {
dokkaPlugin(rootProject.libs.dokka.android)
}
tasks {
withType<Test>().configureEach {
useJUnitPlatform()
filter { isFailOnNoMatchingTests = true }
}
register<org.gradle.jvm.tasks.Jar>("dokkaJavadocJar") {
dependsOn(dokkaJavadoc)
from(dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}
register<org.gradle.jvm.tasks.Jar>("emptyJavadocJar") {
archiveClassifier.set("javadoc")
}
}
plugins.withType<ComposeCompilerGradleSubplugin>().configureEach {
the<ComposeCompilerGradlePluginExtension>().apply {
featureFlags.addAll(OptimizeNonSkippingGroups)
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_definitions.txt")
if (properties["enableComposeCompilerReports"] == "true") {
val metricsDir = layout.buildDirectory.dir("compose_metrics")
metricsDestination = metricsDir
reportsDestination = metricsDir
}
}
}
afterEvaluate {
extensions.findByType<MavenPublishBaseExtension>()?.run {
val isReleaseBuild = properties["release"]?.toString().toBoolean()
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, false)
if (isReleaseBuild) signAllPublications()
coordinates(Config.artifactId, name, Config.version(isReleaseBuild))
pom {
name = Config.name
description = Config.description
url = Config.url
licenses {
license {
name = Config.licenseName
url = Config.licenseUrl
distribution = Config.licenseUrl
}
}
developers {
developer {
id = Config.vendorId
name = Config.vendorName
url = Config.developerUrl
email = Config.supportEmail
organizationUrl = Config.developerUrl
}
}
scm {
url = Config.scmUrl
}
}
}
}
}
doctor {
javaHome {
ensureJavaHomeMatches.set(false)
}
}
dependencyAnalysis {
structure {
ignoreKtx(true)
}
}
dependencies {
detektPlugins(rootProject.libs.detekt.formatting)
detektPlugins(rootProject.libs.detekt.compose)
detektPlugins(rootProject.libs.detekt.libraries)
}
versionCatalogUpdate {
sortByKey = true
versionSelector { stabilityLevel(it.candidate.version) >= Config.minStabilityLevel }
keep {
keepUnusedVersions = true
keepUnusedLibraries = true
keepUnusedPlugins = true
}
}
tasks {
dokkaHtmlMultiModule.configure {
moduleName.set(rootProject.name)
}
// needed to generate compose compiler reports. See /scripts
withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
buildUponDefaultConfig = true
parallel = true
setSource(projectDir)
config.setFrom(File(rootDir, Config.Detekt.configFile))
basePath = projectDir.absolutePath
jvmTarget = Config.jvmTarget.target
include(Config.Detekt.includedFiles)
exclude(Config.Detekt.excludedFiles)
reports {
xml.required.set(false)
html.required.set(true)
txt.required.set(false)
sarif.required.set(true)
md.required.set(false)
}
}
register<io.gitlab.arturbosch.detekt.Detekt>("detektFormat") {
description = "Formats whole project."
autoCorrect = true
}
register<io.gitlab.arturbosch.detekt.Detekt>("detektAll") {
description = "Run detekt on whole project"
autoCorrect = false
}
wrapper {
distributionType = Wrapper.DistributionType.BIN
}
}
rootProject.plugins.withType<YarnPlugin>().configureEach {
rootProject.the<YarnRootExtension>().apply {
yarnLockMismatchReport = YarnLockMismatchReport.WARNING // NONE | FAIL | FAIL_AFTER_BUILD
reportNewYarnLock = true
yarnLockAutoReplace = true
}
}