Skip to content

Commit

Permalink
Merge pull request #3689 from JetBrains/ktl-1139-metadata-jvm-api-refs
Browse files Browse the repository at this point in the history
KTL-1139 Set up publishing of kotlinx-metadata-jvm documentation on kotlinlang.org
  • Loading branch information
nikpachoo authored Jul 21, 2023
2 parents ed29b7c + 97ffce0 commit ea0bcef
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package builds.apiReferences.kotlinx.datetime
import BuildParams.KOTLINX_DATETIME_RELEASE_TAG
import builds.apiReferences.dependsOnDokkaTemplate
import builds.apiReferences.templates.BuildApiReference
import builds.apiReferences.templates.scriptDokkaVersionSync
import builds.apiReferences.templates.buildDokkaHTML
import builds.apiReferences.templates.scriptDropSnapshot
import jetbrains.buildServer.configs.kotlin.BuildType

Expand All @@ -16,7 +16,6 @@ object KotlinxDatetimeBuildApiReference : BuildType({

params {
param("release.tag", KOTLINX_DATETIME_RELEASE_TAG)
param("DOKKA_TEMPLATE_TASK", ":kotlinx-datetime:dokkaHtml")
}

vcs {
Expand All @@ -34,5 +33,8 @@ object KotlinxDatetimeBuildApiReference : BuildType({
sed -i -E "s/versionSuffix=SNAPSHOT//gi" ./gradle.properties
""".trimIndent()
}
buildDokkaHTML {
tasks = ":kotlinx-datetime:dokkaHtml"
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package builds.apiReferences.kotlinx.metadataJvm

import BuildParams.KOTLINX_METADATA_JVM_RELEASE_TAG
import builds.apiReferences.dependsOnDokkaTemplate
import builds.apiReferences.templates.BuildApiReference
import builds.apiReferences.templates.scriptDropSnapshot
import builds.apiReferences.templates.*
import jetbrains.buildServer.configs.kotlin.BuildType
import jetbrains.buildServer.configs.kotlin.triggers.vcs
import jetbrains.buildServer.configs.kotlin.buildSteps.script

object KotlinxMetadataJvmBuildApiReference : BuildType({
name = "kotlinx-metadata-jvm API reference"
Expand All @@ -16,11 +15,10 @@ object KotlinxMetadataJvmBuildApiReference : BuildType({

params {
param("release.tag", KOTLINX_METADATA_JVM_RELEASE_TAG)
param("DOKKA_TEMPLATE_TASK", ":kotlinx-metadata-jvm:dokkaHtml -PkotlinxMetadataDeployVersion=${KOTLINX_METADATA_JVM_RELEASE_TAG}")
}

triggers {
vcs {
vcsDefaultTrigger {
enabled = false
}
}
Expand All @@ -33,6 +31,48 @@ object KotlinxMetadataJvmBuildApiReference : BuildType({
scriptDropSnapshot {
enabled = false
}
buildDokkaHTML {
enabled = false
}
scriptDokkaVersionSync {
scriptContent = """
#!/bin/bash
set -e
set +x
set -o pipefail
set -u
# update Dokka version
sed -i -E "s/dokka ?= ?\"[0-9\.]+\"/dokka = \"%DOKKA_TEMPLATES_VERSION%\"/gi" ./gradle/libs.versions.toml
# Define the replacement string
replacement="maven(url = \"$DOKKA_SPACE_REPO\")\nmavenCentral"
# List of kts files to apply the command on
files=(
"./build.gradle.kts"
"./repo/gradle-settings-conventions/settings.gradle.kts"
"./repo/gradle-build-conventions/buildsrc-compat/build.gradle.kts"
)
# Loop through the files and apply the sed command
for file in "${'$'}{files[@]}"; do
sed -i -E "s|mavenCentral|${'$'}replacement|" "${'$'}file"
done
# modify Groovy file
sed -i -E "s|mavenCentral|maven \{ url \"$DOKKA_SPACE_REPO\" \}\nmavenCentral|" ./settings.gradle
# add Dokka dev artifacts to the list of trusted ones
sed -i -E "s|<trusted-artifacts>|<trusted-artifacts>\n<trust group=\"org.jetbrains.dokka\" />\n|" ./gradle/verification-metadata.xml
""".trimIndent()
}
script {
name = "build api reference"
scriptContent = """
./gradlew :kotlinx-metadata-jvm:dokkaHtml -PkotlinxMetadataDeployVersion=${KOTLINX_METADATA_JVM_RELEASE_TAG}
""".trimIndent()
}
}

dependencies {
Expand Down
30 changes: 21 additions & 9 deletions .teamcity/builds/apiReferences/templates/BuildApiReference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package builds.apiReferences.templates
import BuildParams.DOKKA_TEMPLATES_VERSION
import jetbrains.buildServer.configs.kotlin.BuildSteps
import jetbrains.buildServer.configs.kotlin.Template
import jetbrains.buildServer.configs.kotlin.Trigger
import jetbrains.buildServer.configs.kotlin.Triggers
import jetbrains.buildServer.configs.kotlin.buildSteps.GradleBuildStep
import jetbrains.buildServer.configs.kotlin.buildSteps.ScriptBuildStep
import jetbrains.buildServer.configs.kotlin.buildSteps.gradle
import jetbrains.buildServer.configs.kotlin.triggers.VcsTrigger
import jetbrains.buildServer.configs.kotlin.triggers.vcs

fun BuildSteps.scriptDropSnapshot(block: ScriptBuildStep.() -> Unit) = step(
Expand Down Expand Up @@ -36,6 +39,21 @@ fun BuildSteps.scriptDokkaVersionSync(block: ScriptBuildStep.() -> Unit) = step(
}.apply(block),
)

fun BuildSteps.buildDokkaHTML(block: GradleBuildStep.() -> Unit) = step(
GradleBuildStep {
id = "step-build-dokka-html-id"
name = "Build dokka html"
tasks = "dokkaHtmlMultiModule"
}.apply(block),
)

fun Triggers.vcsDefaultTrigger(block: Trigger.() -> Unit) = trigger(
VcsTrigger {
id = "trigger-vcs-default-trigger-id"
branchFilter = "+:<default>"
}.apply(block)
)

object BuildApiReference : Template({
name = "Dokka Reference Template"

Expand All @@ -44,13 +62,10 @@ object BuildApiReference : Template({
params {
param("teamcity.vcsTrigger.runBuildInNewEmptyBranch", "true")
param("DOKKA_TEMPLATES_VERSION", DOKKA_TEMPLATES_VERSION)
param("DOKKA_TEMPLATE_TASK", "dokkaHtmlMultiModule")
}

triggers {
vcs {
branchFilter = "+:<default>"
}
vcsDefaultTrigger {}
}

requirements {
Expand All @@ -60,9 +75,6 @@ object BuildApiReference : Template({
steps {
scriptDropSnapshot {}
scriptDokkaVersionSync {}
gradle {
name = "Build dokka html"
tasks = "%DOKKA_TEMPLATE_TASK%"
}
buildDokkaHTML {}
}
})
12 changes: 12 additions & 0 deletions .teamcity/builds/kotlinlang/buidTypes/BuildSitePages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package builds.kotlinlang.buidTypes

import builds.apiReferences.kotlinx.coroutines.KotlinxCoroutinesBuildApiReference
import builds.apiReferences.kotlinx.datetime.KotlinxDatetimeBuildApiReference
import builds.apiReferences.kotlinx.metadataJvm.KotlinxMetadataJvmBuildApiReference
import builds.apiReferences.kotlinx.serialization.KotlinxSerializationBuildApiReference
import builds.kotlinlang.templates.DockerImageBuilder
import jetbrains.buildServer.configs.kotlin.*
Expand Down Expand Up @@ -167,6 +168,17 @@ object BuildSitePages : BuildType({
}
}

dependency(KotlinxMetadataJvmBuildApiReference) {
snapshot {
reuseBuilds = ReuseBuilds.NO
onDependencyFailure = FailureAction.FAIL_TO_START
}

artifacts {
artifactRules = "+:pages.zip!** => libs/kotlinx-metadata-jvm/"
}
}

artifacts(AbsoluteId("Kotlin_KotlinRelease_190_LibraryReferenceLegacyDocs")) {
buildRule = tag("publish", """
+:<default>
Expand Down
1 change: 1 addition & 0 deletions docs/kr.tree
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@
<toc-element toc-title="Coroutines (kotlinx.coroutines)" href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/"/>
<toc-element toc-title="Serialization (kotlinx.serialization)" href="https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/"/>
<toc-element toc-title="Date and time (kotlinx-datetime)" href="https://kotlinlang.org/api/kotlinx-datetime/"/>
<toc-element toc-title="JVM Metadata (kotlinx-metadata-jvm)" href="https://kotlinlang.org/api/kotlinx-metadata-jvm/"/>
<toc-element toc-title="Ktor" href="https://api.ktor.io/"/>
</toc-element>

Expand Down

0 comments on commit ea0bcef

Please sign in to comment.