-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
98 lines (87 loc) · 3.05 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
plugins {
buildsrc.conventions.`kotlin-multiplatform`
buildsrc.conventions.`maven-publishing`
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("org.jetbrains.dokka")
}
val publishVersion = project.layout.projectDirectory.file("version.txt").asFile.readText().trim()
group = "me.alllex.parsus"
version = publishVersion
kotlin {
sourceSets {
commonMain {
dependencies {
// Support for multiplatform @Language annotation
compileOnly(libs.annotations)
}
}
nativeMain {
dependencies {
// Required, because compileOnly dependencies are not supported on Kotlin/Native
api(libs.annotations)
}
}
jsMain {
dependencies {
// Required, because compileOnly dependencies are not supported on Kotlin/JS
api(libs.annotations)
}
}
commonTest {
dependencies {
implementation(kotlin("test"))
implementation(libs.assertk)
runtimeOnly(kotlin("reflect"))
}
}
}
}
repositories {
mavenCentral()
}
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
description = "Produce javadoc with Dokka HTML inside"
dependsOn(tasks.dokkaHtml)
from(tasks.dokkaHtml)
archiveClassifier = "javadoc"
}
// Without this there is a Gradle error (notice mismatch between publish task and sign names):
// > Reason: Task ':publishIosArm64PublicationToMavenLocal' uses this output of task ':signIosX64Publication' without declaring an explicit or implicit dependency.
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(tasks.withType<Sign>())
}
// Maven Central publication requires a javadoc jar
publishing {
publications.withType<MavenPublication>().configureEach {
artifact(javadocJar)
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}
}
tasks.register<GenerateQuickReferenceMarkdown>("generateQuickRef") {
kotlinTestSource = project.layout.projectDirectory.file("src/commonTest/kotlin/me/alllex/parsus/ReadmeTests.kt")
markdownOutput = project.layout.buildDirectory.file("quickref.md")
}
tasks.register("checkQuickRefInReadme") {
dependsOn("generateQuickRef")
val generatedQuickRef = project.layout.buildDirectory.file("quickref.md")
val readme = project.layout.projectDirectory.file("README.md")
inputs.file(generatedQuickRef)
inputs.file(readme)
doLast {
val generatedQuickRefString = generatedQuickRef.get().asFile.readText()
val readmeAsString = readme.asFile.readText()
check(readmeAsString.contains(generatedQuickRefString)) {
"Generated quick reference is not present in README.md"
}
}
}
tasks.named("check") {
dependsOn("checkQuickRefInReadme")
}