Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
242 lines (216 loc) · 10.8 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
242 lines (216 loc) · 10.8 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
import sk.ainet.buildlogic.npm.NpmPinTarget
plugins {
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.androidMultiplatformLibrary) apply false
alias(libs.plugins.jetbrainsKotlinJvm) apply false
alias(libs.plugins.vanniktech.mavenPublish) apply false
alias(libs.plugins.kover)
alias(libs.plugins.binary.compatibility.validator) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.asciidoctorJvm) apply false
alias(libs.plugins.dokka)
alias(libs.plugins.skainet.docs)
alias(libs.plugins.skainet.npmPins)
alias(libs.plugins.skainet.mavenPins)
id("org.jetbrains.kotlinx.benchmark") version "0.5.0" apply false
}
allprojects {
group = "sk.ainet.core"
version = providers.gradleProperty("VERSION_NAME").getOrElse("unspecified")
}
// Root-project SKaiNET conventions. npm pins are forced onto the kotlin-js-store
// lockfiles via Yarn resolutions; see docs "Pinning npm Packages".
//
// `ws` is the only pinned package present in both dependency graphs, so it is the only
// unscoped pin. Everything else lives solely in the Kotlin/JS graph and is scoped to it:
// Yarn writes a lockfile entry for every resolutions key whether or not that graph
// requests the package, so an unscoped pin would add the package — and, for webpack, its
// ~76 transitive dependencies — to kotlin-js-store/wasm/yarn.lock for nothing.
skainet {
npmPins {
pin("ws", libs.versions.npm.ws)
pin("js-yaml", libs.versions.npm.js.yaml, NpmPinTarget.JS)
pin("socket.io-parser", libs.versions.npm.socketio.parser, NpmPinTarget.JS)
pin("fast-uri", libs.versions.npm.fast.uri, NpmPinTarget.JS)
pin("serialize-javascript", libs.versions.npm.serialize.javascript, NpmPinTarget.JS)
pin("qs", libs.versions.npm.qs, NpmPinTarget.JS)
pin("brace-expansion", libs.versions.npm.brace.expansion, NpmPinTarget.JS)
pin("diff", libs.versions.npm.diff, NpmPinTarget.JS)
pin("engine.io", libs.versions.npm.engine.io, NpmPinTarget.JS)
}
// Maven pins reach every project configuration and every buildscript (plugin)
// classpath — AGP, Kover, and Dokka ship the flagged versions there.
mavenPins {
pin("org.bouncycastle:bcprov-jdk18on", libs.versions.maven.bouncycastle)
pin("org.bouncycastle:bcpkix-jdk18on", libs.versions.maven.bouncycastle)
pin("org.bouncycastle:bcutil-jdk18on", libs.versions.maven.bouncycastle)
pin("org.freemarker:freemarker", libs.versions.maven.freemarker)
pin("org.apache.commons:commons-lang3", libs.versions.maven.commons.lang3)
pin("org.apache.httpcomponents:httpclient", libs.versions.maven.httpclient)
pin("org.jsoup:jsoup", libs.versions.maven.jsoup)
pin("io.opentelemetry:opentelemetry-api", libs.versions.maven.opentelemetry.api)
// Jackson is pinned to the project's own audited line (already in the catalog
// for skainet's direct use) rather than the advisories' minimum 2.18.11, so the
// pin can never downgrade a project configuration. core moves with databind:
// forcing databind alone would strand core on Dokka's 2.15.3. jackson-annotations
// is deliberately NOT pinned — it has no patch releases (the 2.22 line is just
// "2.22"), so a 2.22.3 pin cannot resolve; databind's bom aligns it instead.
pin("com.fasterxml.jackson.core:jackson-databind", libs.versions.jacksonDatabind)
pin("com.fasterxml.jackson.core:jackson-core", libs.versions.jacksonDatabind)
}
}
// Require JDK 21+ but allow any newer version (produces Java 21 bytecode via --release / jvmTarget)
subprojects {
require(JavaVersion.current() >= JavaVersion.VERSION_21) {
"This project requires JDK 21+, but found ${JavaVersion.current()}"
}
// Kotlin Multiplatform projects – set jvmTarget on every JVM-like target
plugins.withId("org.jetbrains.kotlin.multiplatform") {
extensions.findByType(org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension::class.java)?.apply {
targets.withType(org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget::class.java) {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
}
}
}
}
// Kotlin/JVM projects
plugins.withId("org.jetbrains.kotlin.jvm") {
extensions.findByType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension::class.java)?.apply {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
}
}
}
// Java sources – produce Java 21 bytecode regardless of the JDK used to compile.
// Skip Android projects: AGP manages source/target compatibility itself and rejects --release.
afterEvaluate {
if (!plugins.hasPlugin("com.android.library") && !plugins.hasPlugin("com.android.application") && !plugins.hasPlugin("com.android.kotlin.multiplatform.library")) {
tasks.withType<JavaCompile>().configureEach {
options.release.set(21)
}
}
}
tasks.withType<Test>().configureEach {
maxHeapSize = "8192m"
}
apply(plugin = "org.jetbrains.kotlinx.kover")
}
kover {
reports {
total {
html {
onCheck = true
}
xml {
onCheck = true
}
}
}
}
dependencies {
subprojects.forEach {
kover(it)
}
}
// Custom task to generate operator documentation
tasks.register("generateOperatorDocs") {
group = "documentation"
description = "Generate operator documentation from KSP-generated JSON files"
// Configure inputs for incremental builds
inputs.files("skainet-lang/skainet-lang-core/build/generated/ksp/metadata/commonMain/resources/operators.json")
// Configure outputs for incremental builds
outputs.dir("docs/modules/ROOT/pages/reference/operators/generated")
outputs.cacheIf { true }
// Depend on KSP processing
dependsOn(":skainet-lang:skainet-lang-core:kspCommonMainKotlinMetadata")
// Run built-in documentation generation task (provided by sk.ainet.documentation plugin)
dependsOn("generateDocs")
doLast {
println("Operator documentation generation completed")
}
}
// Documentation plugin configuration — emits operator doc fragments
// into the Antora ROOT module so the published site can surface them
// under Reference > Operator coverage.
documentation {
inputFile.set(file("skainet-lang/skainet-lang-core/build/generated/ksp/metadata/commonMain/resources/operators.json"))
outputDirectory.set(file("docs/modules/ROOT/pages/reference/operators/generated"))
includeBackendStatus.set(true)
generateIndex.set(true)
// Backend `statusByBackend` maps + StableHLO / backward coverage dumps for the matrix.
// The two coverage JSONs come from jvmTests; refresh them before generateDocs with:
// ./gradlew :skainet-compile:skainet-compile-hlo:jvmTest --tests '*HloCoverageDumpTest' \
// :skainet-compile:skainet-compile-dag:jvmTest --tests '*BackwardCoverageDumpTest' generateDocs
// (without them the StableHLO / Backward columns are omitted).
backendStatusFiles.from(file("skainet-backends/skainet-backend-cpu/build/generated/ksp/metadata/commonMain/resources/operators.json"))
hloCoverageFile.set(file("skainet-compile/skainet-compile-hlo/build/generated/coverage/hlo-coverage.json"))
backwardCoverageFile.set(file("skainet-compile/skainet-compile-dag/build/generated/coverage/backward-coverage.json"))
// Kernel × platform matrix — registry-introspected JSON (emitted by KernelSupportMatrixTest)
// rendered to an Antora page, mirroring the operators.json → ops-status-matrix.adoc pipeline.
kernelInputFile.set(file("skainet-backends/skainet-backend-native-cpu/build/generated/kernel-support/kernel-support.json"))
kernelOutputFile.set(file("docs/modules/ROOT/pages/reference/kernel-support-matrix.adoc"))
}
tasks.named("generateDocs") {
dependsOn(":skainet-lang:skainet-lang-core:kspCommonMainKotlinMetadata")
dependsOn(":skainet-backends:skainet-backend-cpu:kspCommonMainKotlinMetadata")
// The coverage dumps are opt-in (see the regenerate command above), but when they are
// requested in the same invocation they must finish before the matrix is rendered.
mustRunAfter(
":skainet-compile:skainet-compile-hlo:jvmTest",
":skainet-compile:skainet-compile-dag:jvmTest",
)
}
tasks.named("generateKernelMatrix") {
// The generator test introspects the registered providers + emits kernel-support.json.
dependsOn(":skainet-backends:skainet-backend-native-cpu:jvmTest")
}
// Dokka aggregation – unified API reference across all library modules
dokka {
moduleName.set("SKaiNET")
dokkaPublications.html {
includes.from("README.md")
}
}
dependencies {
// skainet-lang
dokka(project(":skainet-lang:skainet-lang-core"))
dokka(project(":skainet-lang:skainet-lang-models"))
dokka(project(":skainet-lang:skainet-lang-ksp-annotations"))
dokka(project(":skainet-lang:skainet-lang-dag"))
// skainet-compile
dokka(project(":skainet-compile:skainet-compile-core"))
dokka(project(":skainet-compile:skainet-compile-dag"))
dokka(project(":skainet-compile:skainet-compile-json"))
dokka(project(":skainet-compile:skainet-compile-hlo"))
dokka(project(":skainet-compile:skainet-compile-c"))
// skainet-backends
dokka(project(":skainet-backends:skainet-backend-cpu"))
// skainet-data
dokka(project(":skainet-data:skainet-data-api"))
dokka(project(":skainet-data:skainet-data-source"))
dokka(project(":skainet-data:skainet-data-transform"))
dokka(project(":skainet-data:skainet-data-simple"))
dokka(project(":skainet-data:skainet-data-media"))
// skainet-io
dokka(project(":skainet-io:skainet-io-core"))
dokka(project(":skainet-io:skainet-io-gguf"))
dokka(project(":skainet-io:skainet-io-image"))
dokka(project(":skainet-io:skainet-io-onnx"))
dokka(project(":skainet-io:skainet-io-safetensors"))
// Other
dokka(project(":skainet-pipeline"))
}
// Copy the Dokka-generated HTML aggregate into the Antora site
// output as a sibling `/api/` path. Invoked by .github/workflows/docs.yml
// AFTER Antora has populated `docs/build/site/`; intentionally NOT
// wired into the `build` lifecycle so that running `./gradlew build`
// locally never silently creates a half-populated site directory.
tasks.register<Copy>("bundleDokkaIntoSite") {
group = "documentation"
description = "Copy build/dokka/html into docs/build/site/api for GitHub Pages publish"
dependsOn("dokkaGenerate")
from(layout.buildDirectory.dir("dokka/html"))
into(layout.projectDirectory.dir("docs/build/site/api"))
}