-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
190 lines (166 loc) · 5.59 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
/*
* Copyright (c) 2023-2024 Elide Technologies, Inc.
*
* Licensed under the MIT license (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://opensource.org/license/mit/
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under the License.
*/
@file:Suppress("PropertyName")
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
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
plugins {
kotlin("multiplatform") version "2.1.0" apply false
kotlin("plugin.serialization") version "2.1.0" apply false
alias(libs.plugins.testlogger) apply false
alias(libs.plugins.kotlinx.benchmark) apply false
alias(libs.plugins.dokka)
alias(libs.plugins.versionCheck)
alias(libs.plugins.sonar)
alias(libs.plugins.kover)
alias(libs.plugins.detekt)
alias(libs.plugins.nexus)
alias(libs.plugins.spdx.sbom)
alias(libs.plugins.cyclonedx)
alias(libs.plugins.sigstore)
alias(libs.plugins.kotlinx.apiValidator)
`project-report`
signing
}
val enableSbom = true
val enableCyclonedx = false
val GROUP: String by properties
val VERSION: String by properties
val sonarScan: String by properties
val nodeVersion: String by properties
val lockDeps: String by properties
val isReleaseBuild = !VERSION.contains("SNAPSHOT")
group = GROUP
version = VERSION
detekt {
parallel = true
ignoreFailures = true
config.setFrom(rootProject.files(".github/detekt.yml"))
}
sonar {
properties {
listOf(
"sonar.projectKey" to "elide-dev_uuid",
"sonar.organization" to "elide-dev",
"sonar.host.url" to "https://sonarcloud.io",
"sonar.coverage.jacoco.xmlReportPaths" to "${project.rootDir}/build/reports/kover/report.xml",
).forEach { (key, value) ->
property(key, value)
}
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}
}
tasks.cyclonedxBom {
setIncludeConfigs(listOf("jvmRuntimeClasspath"))
setProjectType("library")
setDestination(project.file("build/reports"))
setOutputFormat("all")
setIncludeBomSerialNumber(true)
setComponentVersion("2.0.0")
}
tasks.build {
if (isReleaseBuild) {
finalizedBy(":subprojects:uuid-core:spdxSbomForRelease")
}
}
subprojects {
apply(plugin = "dev.sigstore.sign")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jetbrains.kotlinx.kover")
apply(plugin = "org.sonarqube")
apply(plugin = "signing")
}
val reports: TaskProvider<Task> by tasks.registering {
group = "reports"
dependsOn(
tasks.koverXmlReport,
tasks.dependencyReport,
tasks.htmlDependencyReport,
)
}
val preMerge: TaskProvider<Task> by tasks.registering {
group = "test"
description = "Run all tests and checks"
listOfNotNull(
tasks.build,
tasks.check,
tasks.koverXmlReport,
if (enableSbom) tasks.spdxSbom else null,
if (enableCyclonedx) tasks.cyclonedxBom else null,
reports,
).forEach {
dependsOn(it)
}
if (sonarScan == "true") {
dependsOn(
tasks.sonar,
)
}
}
rootProject.plugins.withType(NodeJsRootPlugin::class.java) {
rootProject.the<NodeJsRootExtension>().download = true
rootProject.the<NodeJsRootExtension>().version = nodeVersion
if (nodeVersion.contains("canary")) {
rootProject.the<NodeJsRootExtension>().downloadBaseUrl = "https://nodejs.org/download/v8-canary"
}
}
rootProject.plugins.withType(YarnPlugin::class.java) {
rootProject.the<YarnRootExtension>().yarnLockMismatchReport = YarnLockMismatchReport.WARNING
rootProject.the<YarnRootExtension>().reportNewYarnLock = false
rootProject.the<YarnRootExtension>().yarnLockAutoReplace = true
}
tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java).configureEach {
args.add("--ignore-engines")
}
plugins.withType(io.gitlab.arturbosch.detekt.DetektPlugin::class) {
tasks.withType(io.gitlab.arturbosch.detekt.Detekt::class) detekt@{
reports.sarif.required = true
reports.sarif.outputLocation = rootProject.layout.buildDirectory.file("reports/detekt/report.sarif")
}
}
if (lockDeps == "true") {
dependencyLocking {
lockAllConfigurations()
lockMode = LockMode.LENIENT
}
}
val resolveAndLockAll: TaskProvider<Task> by tasks.registering {
group = "build"
description = "Resolve and re-lock all dependencies"
doFirst {
require(gradle.startParameter.isWriteDependencyLocks)
}
doLast {
configurations.filter {
// Add any custom filtering on the configurations to be resolved
it.isCanBeResolved
}.forEach { it.resolve() }
}
}
val relock: TaskProvider<Task> by tasks.registering {
group = "build"
description = "Re-lock all dependencies"
dependsOn(
tasks.dependencies,
resolveAndLockAll,
)
}