From 1e9122ef8410690d7181f46b6fdd255a6da00697 Mon Sep 17 00:00:00 2001 From: Nikolay Pachkov Date: Wed, 19 Jul 2023 09:35:26 +0200 Subject: [PATCH 1/5] ktl-1139 fix: metadata-jvm api reference build --- .../KotlinxDatetimeBuildApiReference.kt | 6 ++-- .../KotlinxMetadataJvmBuildApiReference.kt | 16 ++++++++-- .../templates/BuildApiReference.kt | 30 +++++++++++++------ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/.teamcity/builds/apiReferences/kotlinx/datetime/KotlinxDatetimeBuildApiReference.kt b/.teamcity/builds/apiReferences/kotlinx/datetime/KotlinxDatetimeBuildApiReference.kt index fd3f787c904..c2dbc884a4c 100644 --- a/.teamcity/builds/apiReferences/kotlinx/datetime/KotlinxDatetimeBuildApiReference.kt +++ b/.teamcity/builds/apiReferences/kotlinx/datetime/KotlinxDatetimeBuildApiReference.kt @@ -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 @@ -16,7 +16,6 @@ object KotlinxDatetimeBuildApiReference : BuildType({ params { param("release.tag", KOTLINX_DATETIME_RELEASE_TAG) - param("DOKKA_TEMPLATE_TASK", ":kotlinx-datetime:dokkaHtml") } vcs { @@ -34,5 +33,8 @@ object KotlinxDatetimeBuildApiReference : BuildType({ sed -i -E "s/versionSuffix=SNAPSHOT//gi" ./gradle.properties """.trimIndent() } + buildDokkaHTML { + tasks = ":kotlinx-datetime:dokkaHtml" + } } }) diff --git a/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt b/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt index 63c33b9722f..d068cb584eb 100644 --- a/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt +++ b/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt @@ -3,9 +3,11 @@ 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.buildDokkaHTML import builds.apiReferences.templates.scriptDropSnapshot +import builds.apiReferences.templates.vcsDefaultTrigger 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" @@ -16,11 +18,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 } } @@ -33,6 +34,15 @@ object KotlinxMetadataJvmBuildApiReference : BuildType({ scriptDropSnapshot { enabled = false } + buildDokkaHTML { + enabled = false + } + script { + name = "build api reference" + scriptContent = """ + ./gradlew :kotlinx-metadata-jvm:dokkaHtml -PkotlinxMetadataDeployVersion=${KOTLINX_METADATA_JVM_RELEASE_TAG} + """.trimIndent() + } } dependencies { diff --git a/.teamcity/builds/apiReferences/templates/BuildApiReference.kt b/.teamcity/builds/apiReferences/templates/BuildApiReference.kt index e32c2ce60a0..fe1bfb00681 100644 --- a/.teamcity/builds/apiReferences/templates/BuildApiReference.kt +++ b/.teamcity/builds/apiReferences/templates/BuildApiReference.kt @@ -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( @@ -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 = "+:" + }.apply(block) +) + object BuildApiReference : Template({ name = "Dokka Reference Template" @@ -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 = "+:" - } + vcsDefaultTrigger {} } requirements { @@ -60,9 +75,6 @@ object BuildApiReference : Template({ steps { scriptDropSnapshot {} scriptDokkaVersionSync {} - gradle { - name = "Build dokka html" - tasks = "%DOKKA_TEMPLATE_TASK%" - } + buildDokkaHTML {} } }) From ae74c6ea8a3e1d7eb31bb98a176493b9aef9b51a Mon Sep 17 00:00:00 2001 From: Nikolay Pachkov Date: Wed, 19 Jul 2023 10:05:12 +0200 Subject: [PATCH 2/5] ktl-1139 chore: add metadata-jvm api to the docs --- .../builds/kotlinlang/buidTypes/BuildSitePages.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.teamcity/builds/kotlinlang/buidTypes/BuildSitePages.kt b/.teamcity/builds/kotlinlang/buidTypes/BuildSitePages.kt index 05349979a3c..23c9ad2304c 100644 --- a/.teamcity/builds/kotlinlang/buidTypes/BuildSitePages.kt +++ b/.teamcity/builds/kotlinlang/buidTypes/BuildSitePages.kt @@ -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.* @@ -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", """ +: From 0a760be59a027ead260755543014f5cc57260246 Mon Sep 17 00:00:00 2001 From: Nikolay Pachkov Date: Wed, 19 Jul 2023 21:35:36 +0200 Subject: [PATCH 3/5] ktl-1139 chore: use dev version Dokka for metadata-jvm api refs --- .../KotlinxMetadataJvmBuildApiReference.kt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt b/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt index d068cb584eb..0c309eef996 100644 --- a/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt +++ b/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt @@ -2,10 +2,7 @@ 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.buildDokkaHTML -import builds.apiReferences.templates.scriptDropSnapshot -import builds.apiReferences.templates.vcsDefaultTrigger +import builds.apiReferences.templates.* import jetbrains.buildServer.configs.kotlin.BuildType import jetbrains.buildServer.configs.kotlin.buildSteps.script @@ -37,6 +34,24 @@ object KotlinxMetadataJvmBuildApiReference : BuildType({ buildDokkaHTML { enabled = false } + scriptDokkaVersionSync { + scriptContent = """ + #!/bin/bash + set -e + set +x + set -o pipefail + set -u + + sed -i -E "s/dokka ?= ?\"[0-9\.]+\"/dokka = \"%DOKKA_TEMPLATES_VERSION%\"/gi" ./gradle/libs.versions.toml + + sed -i -E "s|mavenCentral|maven(url = \"$DOKKA_SPACE_REPO\")\nmavenCentral|" ./build.gradle.kts + sed -i -E "s|mavenCentral|maven(url = \"$DOKKA_SPACE_REPO\")\nmavenCentral|" ./repo/gradle-settings-conventions/settings.gradle.kts + sed -i -E "s|mavenCentral|maven(url = \"$DOKKA_SPACE_REPO\")\nmavenCentral|" ./repo/gradle-build-conventions/buildsrc-compat/build.gradle.kts + sed -i -E "s|mavenCentral|maven \{ url \"$DOKKA_SPACE_REPO\" \}\nmavenCentral|" ./settings.gradle + + sed -i -E "s||\n\n|" ./gradle/verification-metadata.xml + """.trimIndent() + } script { name = "build api reference" scriptContent = """ From 3c52365ddaee34c54997187450516b88f4195147 Mon Sep 17 00:00:00 2001 From: Nikolay Pachkov Date: Thu, 20 Jul 2023 15:27:02 +0200 Subject: [PATCH 4/5] ktl-1139 chore: add JVM Metadata reference to TOC --- docs/kr.tree | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/kr.tree b/docs/kr.tree index 683dfbb3f25..910a808f5a6 100644 --- a/docs/kr.tree +++ b/docs/kr.tree @@ -327,6 +327,7 @@ + From 97ffce0488b45e4d6dbd732e7f6127208ff3d729 Mon Sep 17 00:00:00 2001 From: Nikolay Pachkov Date: Fri, 21 Jul 2023 13:52:49 +0200 Subject: [PATCH 5/5] ktl-1139 chore: refactor JVM Metadata reference DSL config --- .../KotlinxMetadataJvmBuildApiReference.kt | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt b/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt index 0c309eef996..aa7ec34c81e 100644 --- a/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt +++ b/.teamcity/builds/apiReferences/kotlinx/metadataJvm/KotlinxMetadataJvmBuildApiReference.kt @@ -42,13 +42,28 @@ object KotlinxMetadataJvmBuildApiReference : BuildType({ set -o pipefail set -u + # update Dokka version sed -i -E "s/dokka ?= ?\"[0-9\.]+\"/dokka = \"%DOKKA_TEMPLATES_VERSION%\"/gi" ./gradle/libs.versions.toml - sed -i -E "s|mavenCentral|maven(url = \"$DOKKA_SPACE_REPO\")\nmavenCentral|" ./build.gradle.kts - sed -i -E "s|mavenCentral|maven(url = \"$DOKKA_SPACE_REPO\")\nmavenCentral|" ./repo/gradle-settings-conventions/settings.gradle.kts - sed -i -E "s|mavenCentral|maven(url = \"$DOKKA_SPACE_REPO\")\nmavenCentral|" ./repo/gradle-build-conventions/buildsrc-compat/build.gradle.kts + # 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||\n\n|" ./gradle/verification-metadata.xml """.trimIndent() }