-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
94 lines (82 loc) · 3.17 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
import kotlinx.validation.ExperimentalBCVApi
plugins {
`dokka-convention`
alias(libs.plugins.kotlinx.binary.compatibility.validator)
}
dependencies {
dokka(projects.couchbaseLite)
dokka(projects.couchbaseLiteEe)
dokka(projects.couchbaseLiteKtx)
dokka(projects.couchbaseLiteEeKtx)
dokka(projects.couchbaseLiteKermit)
dokka(projects.couchbaseLiteEeKermit)
dokka(projects.couchbaseLitePaging)
dokka(projects.couchbaseLiteEePaging)
}
allprojects {
group = property("GROUP") as String
val cblVersion = rootProject.libs.versions.couchbase.lite.java.get()
val kotbaseVersion = property("VERSION") as String
version = "$cblVersion-$kotbaseVersion"
}
tasks.dokkaGeneratePublicationHtml {
val apiDocsDir = projectDir.resolve("docs/api")
val olderDir = apiDocsDir.resolve("older")
val shortVersion = """\d+\.\d+""".toRegex()
.find(version.toString())!!
.groupValues.first()
dokka.pluginsConfiguration.versioning {
olderVersionsDir = olderDir
version = shortVersion
}
doFirst {
val versionJson = apiDocsDir.resolve("version.json")
if (versionJson.exists()) {
val currentDocsVersion = """"version"\s*:\s*"(\d+\.\d+)"""".toRegex()
.find(versionJson.readText())!!
.groupValues[1]
if (currentDocsVersion != shortVersion) {
val tempOlderDir = apiDocsDir.parentFile.resolve("older")
olderDir.renameTo(tempOlderDir)
val archiveDir = tempOlderDir.resolve(currentDocsVersion)
apiDocsDir.renameTo(archiveDir)
apiDocsDir.mkdir()
tempOlderDir.renameTo(olderDir)
}
}
}
doLast {
apiDocsDir.deleteRecursively()
outputDirectory.get().asFile.renameTo(apiDocsDir)
// work around https://github.com/Kotlin/dokka/issues/3965
fun removeExtraNewlines(dir: File) {
dir.listFiles()?.forEach { file ->
if (file.isDirectory) {
removeExtraNewlines(file)
} else if (file.extension == "html") {
val contents = file.readText().dropLast(1)
file.writeText(contents)
}
}
}
removeExtraNewlines(olderDir)
}
}
apiValidation {
ignoredProjects += listOf("testing-support", "testing-support-ee")
ignoredClasses += listOf(
"dev.kotbase.BuildConfig",
"dev.kotbase.ktx.BuildConfig",
"dev.kotbase.paging.BuildConfig",
"dev.kotbase.kermit.BuildConfig"
)
@OptIn(ExperimentalBCVApi::class)
klib.enabled = true
}
// Workaround to avoid potential configuration error.
// Execution failed for task ':lib:podspec'.
// > Error while evaluating property 'gradleWrapperPath$kotlin_gradle_plugin_common' of task ':lib:podspec'.
// > Failed to calculate the value of task ':lib:podspec' property 'gradleWrapperPath$kotlin_gradle_plugin_common'.
// > java.util.ConcurrentModificationException (no error message)
// https://kotlinlang.slack.com/archives/C3PQML5NU/p1685525274855969?thread_ts=1685426418.942459&cid=C3PQML5NU
tasks.getByName("wrapper")