-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
103 lines (88 loc) · 3.53 KB
/
build.gradle.kts
File metadata and controls
103 lines (88 loc) · 3.53 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
import com.sun.net.httpserver.HttpExchange
import com.sun.net.httpserver.HttpServer
import java.net.InetSocketAddress
import java.net.URLDecoder
import java.nio.file.Files
plugins {
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.multiplatform.library) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.skie) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.mavenPublishPlugin) apply false
alias(libs.plugins.downloadPlugin) apply false
alias(libs.plugins.kotlinter) apply false
alias(libs.plugins.cocoapods) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.androidx.room) apply false
id("org.jetbrains.dokka") version libs.versions.dokkaBase
id("dokka-convention")
}
tasks.getByName<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
// Merges individual module docs into a single HTML output
dependencies {
dokka(projects.common)
dokka(projects.core)
dokka(projects.compose)
dokka(projects.integrations.room)
dokka(projects.integrations.sqldelight)
dokka(projects.integrations.supabase)
dokka(projects.sqlite3multipleciphers)
}
dokka {
moduleName.set("PowerSync Kotlin")
}
develocity {
val isPowerSyncCI = System.getenv("GITHUB_REPOSITORY") == "powersync-ja/powersync-kotlin"
buildScan {
// We can't know if everyone running this build has accepted the TOS, but we've accepted
// them for our CI.
if (isPowerSyncCI) {
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
termsOfUseAgree.set("yes")
}
// Only upload build scan if the --scan parameter is set
publishing.onlyIf { false }
}
}
// Serve the generated Dokka documentation using a simple HTTP server
// File changes are not watched here
tasks.register("serveDokka") {
group = "dokka"
dependsOn("dokkaGenerate")
val rootProvider = layout.buildDirectory.dir("dokka/html")
doLast {
val root = rootProvider.get().asFile
val server = HttpServer.create(InetSocketAddress(0), 0)
val handler =
com.sun.net.httpserver.HttpHandler { exchange: HttpExchange ->
val rawPath = exchange.requestURI.path
val cleanPath = URLDecoder.decode(rawPath.removePrefix("/"), "UTF-8")
val requestedFile = File(root, cleanPath)
val file =
when {
requestedFile.exists() && !requestedFile.isDirectory -> requestedFile
else -> File(root, "index.html") // fallback
}
val contentType =
Files.probeContentType(file.toPath()) ?: "application/octet-stream"
val bytes = file.readBytes()
exchange.responseHeaders.add("Content-Type", contentType)
exchange.sendResponseHeaders(200, bytes.size.toLong())
exchange.responseBody.use { it.write(bytes) }
}
server.createContext("/", handler)
server.executor = null
server.start()
println("📘 Serving Dokka docs at http://localhost:${server.address.port}/")
println("Press Ctrl+C to stop.")
// Keep the task alive
Thread.currentThread().join()
}
}