-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
167 lines (151 loc) · 5.49 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
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.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.atomicfu)
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.maven.publish) 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
}
allprojects {
group = Config.artifactId
version = Config.versionName
}
subprojects {
plugins.withType<ComposeCompilerGradleSubplugin>().configureEach {
the<ComposeCompilerGradlePluginExtension>().apply {
enableIntrinsicRemember = true
enableNonSkippingGroupOptimization = true
enableStrongSkippingMode = true
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
}
}
}
}
tasks {
withType<Test>().configureEach {
useJUnitPlatform()
filter { isFailOnNoMatchingTests = true }
}
withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(Config.jvmTarget)
freeCompilerArgs.apply { addAll(Config.jvmCompilerArgs) }
optIn.addAll(Config.optIns.map { "-opt-in=$it" })
}
}
}
if (name == "app") return@subprojects
apply(plugin = rootProject.libs.plugins.dokka.id)
dependencies {
dokkaPlugin(rootProject.libs.dokka.android)
}
}
doctor {
javaHome {
ensureJavaHomeMatches.set(false)
}
}
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
}
}
atomicfu {
dependenciesVersion = libs.versions.atomicfu.get()
transformJvm = false
jvmVariant = "VH"
transformJs = false
}
tasks {
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
}
}
rootProject.plugins.withType<YarnPlugin>().configureEach {
rootProject.the<YarnRootExtension>().apply {
yarnLockMismatchReport = YarnLockMismatchReport.WARNING // NONE | FAIL | FAIL_AFTER_BUILD
reportNewYarnLock = true
yarnLockAutoReplace = true
}
}