-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
299 lines (254 loc) · 12.9 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
299 lines (254 loc) · 12.9 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
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
297
298
299
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import java.util.*
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.binary.compatibility.validator)
alias(libs.plugins.dependency.check)
}
group = "net.postchain.rell"
version = "0.17.0-SNAPSHOT"
description = "Rell programming language"
// Load local.properties (not committed) for machine-specific settings like Docker socket paths.
val localProperties = Properties().apply {
rootProject.file("local.properties").takeIf { it.exists() }?.inputStream()?.use { load(it) }
}
apiValidation {
ignoredProjects += listOf(
"rell-base", "rr-serialization", "utils", "test-utils", "rell-gtx", "rell-tools",
"frontend", "runtime-core", "runtime-interpreter", "runtime-truffle",
// Imported projects — no API stability guarantees yet
"rell-toolbox", "common", "ast", "indexer", "code-quality", "language-server", "seeder",
"rell-codegen", "codegen", "codegen-kotlin", "codegen-typescript", "codegen-javascript",
"codegen-python", "codegen-mermaid", "rellgen",
"performance",
"regression",
)
}
dependencyCheck {
formats = listOf("HTML", "JSON")
failBuildOnCVSS = 0f
suppressionFiles = listOf(
"https://gitlab.com/chromaway/chromia-parent/-/raw/dev/common-dependencies-suppression.xml?ref_type=heads",
"dependencies-suppression.xml",
)
analyzers.assemblyEnabled = false
// Without an NVD API key the NIST endpoint rate-limits us into HTTP 429 within a few
// minutes (see CI: 30+ retries, then "Error updating the NVD Data"). Request one at
// https://nvd.nist.gov/developers/request-an-api-key and expose it as the NVD_API_KEY
// CI variable; local runs without the env var keep working (just slowly).
nvd.apiKey = providers.environmentVariable("NVD_API_KEY").orNull
}
val withLocales by extra(providers.gradleProperty("withLocales").isPresent)
// Aggregator: publish every Rell module to ~/.m2 within this build graph. The chr bootstrap
// (:performance:buildLocalChr) depends on this instead of shelling out to a nested
// `./gradlew publishToMavenLocal` — a nested Gradle deadlocks on the journal-cache lock.
val publishRellToMavenLocal by tasks.registering {
group = "publishing"
description = "Publish all Rell modules to the local Maven repository (used by the chr bootstrap)."
}
subprojects {
group = rootProject.group
version = rootProject.version
plugins.withId("org.jetbrains.kotlin.jvm") {
apply(plugin = "jacoco")
apply(plugin = "maven-publish")
apply(plugin = "signing")
dependencies {
"implementation"(platform(rootProject.libs.postchain.bom))
"testImplementation"(platform(rootProject.libs.junit.bom))
"testImplementation"(rootProject.libs.junit.platform.launcher)
}
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion = JavaLanguageVersion.of(21)
withSourcesJar()
withJavadocJar()
}
extensions.configure<KotlinJvmProjectExtension> {
compilerOptions.jvmTarget = JvmTarget.JVM_21
}
tasks.withType<Test> {
useJUnitPlatform()
// Include integration-test style classes as Maven Failsafe did
include("**/*Test.*", "**/*Tests.*", "**/*TestCase.*", "**/*IT.*")
systemProperty("java.awt.headless", "true")
// Forward Docker config to test JVM for Testcontainers.
// local.properties values take precedence over environment variables.
listOf(
"DOCKER_HOST",
"DOCKER_TLS_CERTDIR",
"TESTCONTAINERS_HOST_OVERRIDE",
"TESTCONTAINERS_RYUK_DISABLED",
"TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE",
"TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX",
).forEach { key ->
val value = localProperties.getProperty(key) ?: providers.environmentVariable(key).orNull
if (value != null) environment(key, value)
}
val dockerHost = localProperties.getProperty("DOCKER_HOST")
?: providers.environmentVariable("DOCKER_HOST").orNull
if (dockerHost != null) systemProperty("docker.host", dockerHost)
// Test JVM heap. Default suits 16 GiB dev machines; CI overrides via -PtestJvmMaxHeap.
// Bumped from 2g to 4g after rell-base sub-module split added RR tree + FlatBuffers to the classpath.
maxHeapSize = providers.gradleProperty("testJvmMaxHeap").orElse("4g").get()
systemProperty("junit.jupiter.execution.parallel.enabled", "true")
systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent")
systemProperty("junit.jupiter.execution.parallel.mode.classes.default", "concurrent")
// JUnit ForkJoinPool parallelism per test worker.
// Default (dynamic/1) uses availableProcessors(), which over-subscribes when
// Gradle also runs --max-workers test tasks. Use "fixed" strategy so CI can
// cap it via -PjunitParallelThreads (e.g. 4 workers × 4 threads = 16 cores).
providers.gradleProperty("junitParallelThreads").orNull?.let { threads ->
systemProperty("junit.jupiter.execution.parallel.config.strategy", "fixed")
systemProperty("junit.jupiter.execution.parallel.config.fixed.parallelism", threads)
}
// maxParallelForks = 1: Only one test worker JVM within this task.
// forkEvery = 0: Reuse the same JVM for all tests (no per-class forking).
maxParallelForks = 1
forkEvery = 0
// Test-snippet recorder: opt in per-invocation with `-Ptest.snippets.recorder.enabled=true`.
// Forcing it on for every Test task wrote tens of thousands of snippets to
// `<module>/build/rell-test-cases` on every CI run, even for unrelated suites. The
// recorder is only meaningful when paired with grammar/parser correctness work.
if (providers.gradleProperty("test.snippets.recorder.enabled").orNull?.toBoolean() == true) {
systemProperty("test.snippets.recorder.enabled", "true")
systemProperty(
"test.snippets.recorder.target",
layout.buildDirectory.dir("rell-test-cases").get().asFile.absolutePath,
)
systemProperty("test.snippets.recorder.zipfile", "false")
}
testLogging {
events("passed", "skipped", "failed")
showExceptions = true
showCauses = true
showStackTraces = true
}
finalizedBy(tasks.named("jacocoTestReport"))
}
// When -PwithLocales is passed, register similar Test tasks per locale and wire them into `check`.
// Skip non-blockchain modules — they have no determinism requirement.
val localeExcludedPrefixes = listOf("rell-dokka-plugin", "rell-codegen", "rell-toolbox")
if (withLocales && localeExcludedPrefixes.none { project.path.startsWith(":$it") }) {
data class TestLocale(val language: String, val country: String, val name: String)
val testLocales = listOf(
TestLocale("tr", "TR", "Turkish"),
TestLocale("ar", "SA", "Arabic"),
TestLocale("ja", "JP", "Japanese"),
)
val mainTest = tasks.named<Test>("test")
var previousTask = mainTest
for (locale in testLocales) {
val localeTestTask = tasks.register<Test>("test${locale.name}") {
description = "Runs tests with locale ${locale.language}_${locale.country}"
group = LifecycleBasePlugin.VERIFICATION_GROUP
testClassesDirs = mainTest.get().testClassesDirs
classpath = mainTest.get().classpath
jvmArgs("-Duser.language=${locale.language}", "-Duser.country=${locale.country}")
mustRunAfter(previousTask)
}
tasks.named("check") {
dependsOn(localeTestTask)
}
previousTask = localeTestTask
}
}
tasks.withType<JacocoReport> {
// Exclude opt-in Test tasks (e.g. :rell-toolbox:ast:grammarTest) from Jacoco wiring,
// otherwise `test`'s `finalizedBy(jacocoTestReport)` would transitively run them.
dependsOn(tasks.withType<Test>().matching { it.name !in setOf("grammarTest") })
reports {
xml.required = true
html.required = true
}
}
tasks.withType<Jar>().configureEach {
manifest {
attributes(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Specification-Title" to project.name,
"Specification-Version" to project.version,
)
}
}
extensions.configure<PublishingExtension> {
repositories {
mavenLocal()
if (providers.gradleProperty("gitlabAuthHeaderValue").isPresent) {
maven {
name = "gitlab"
url = uri("https://gitlab.com/api/v4/projects/32802097/packages/maven")
credentials(HttpHeaderCredentials::class)
authentication {
create<HttpHeaderAuthentication>("header")
}
}
}
}
publications.create<MavenPublication>("mavenJava") {
from(components["java"])
// Relocated artifacts: new names under net.postchain.rell to avoid
// version conflicts with independently-versioned legacy registries.
when {
project.path.startsWith(":rell-toolbox:") -> artifactId = "rell-toolbox-${project.name}"
project.path.startsWith(":rell-codegen:") -> artifactId = "rell-${project.name}"
}
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
pom {
name = project.name
description = project.description
url = "https://rell.chromia.com"
inceptionYear = "2018"
licenses {
license {
name = "GNU General Public License v3.0 with additional linking exceptions"
url = "https://www.gnu.org/licenses/gpl-3.0.en.html"
}
}
developers {
developer {
id = "iaroslav.postovalov"
name = "Iaroslav Postovalov"
email = "iaroslav.postovalov@chromaway.com"
organization = "ChromaWay"
organizationUrl = "https://chromaway.com"
roles = listOf("maintainer")
timezone = "Europe/Berlin"
}
}
scm {
connection = "scm:git:git://gitlab.com/chromaway/rell.git"
developerConnection = "scm:git:ssh://gitlab.com:chromaway/rell.git"
url = "https://gitlab.com/chromaway/rell"
}
}
}
}
extensions.configure<SigningExtension> {
val signingKey = providers.gradleProperty("signingKey").orNull
val signingPassword = providers.gradleProperty("signingPassword").orNull
isRequired = signingKey != null
if (signingKey != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
val publishing = extensions.getByType(PublishingExtension::class.java)
sign(publishing.publications["mavenJava"])
}
}
// Feed this module's publishToMavenLocal into the aggregator the chr bootstrap depends on.
// The toolkits themselves are excluded — chr builds against the Rell artifacts, not these.
if (project.path != ":regression" && project.path != ":performance") {
rootProject.tasks.named("publishRellToMavenLocal").configure {
dependsOn(tasks.named("publishToMavenLocal"))
}
}
}
}