Skip to content

Commit af64ee2

Browse files
authored
Merge pull request #4834 from JetBrains/compose-multiplatform-core
KTL-2474: Add story-tales
2 parents 406a065 + 98fafd9 commit af64ee2

File tree

59 files changed

+633
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+633
-258
lines changed

.teamcity/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

.teamcity/BuildParams.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import references.builds.compose.ComposeMultiplatformCore
2+
13
object BuildParams {
24
const val DOKKA_TEMPLATES_VERSION = "2.0.0"
35

@@ -36,6 +38,10 @@ object BuildParams {
3638
const val KOTLINX_METADATA_RELEASE_TAG = KOTLIN_RELEASE_TAG
3739
const val KOTLINX_METADATA_TITLE = KOTLINX_METADATA_ID
3840

41+
val API_COMPOSE = ComposeMultiplatformCore {
42+
addVersion("1.8.0", "api-reference/1.8")
43+
}
44+
3945
const val SEARCH_APP_ID = "7961PKYRXV"
4046
const val SEARCH_INDEX_NAME = "prod_KOTLINLANG_WEBHELP"
4147

@@ -47,5 +53,6 @@ object BuildParams {
4753
"api/$KOTLINX_IO_ID",
4854
"api/$KGP_ID",
4955
"api/$KOTLINX_METADATA_ID",
56+
"api/${API_COMPOSE.urlPart}",
5057
)
5158
}

.teamcity/builds/apiReferences/BuildApiReferencesProject.kt

Lines changed: 0 additions & 66 deletions
This file was deleted.

.teamcity/builds/kotlinlang/SiteProject.kt

Lines changed: 0 additions & 42 deletions
This file was deleted.

.teamcity/common/ReferenceProject.kt

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package common
2+
3+
import common.extensions.scriptGenerateSitemap
4+
import common.extensions.scriptNoRobots
5+
import jetbrains.buildServer.configs.kotlin.BuildType
6+
import jetbrains.buildServer.configs.kotlin.Project
7+
import jetbrains.buildServer.configs.kotlin.RelativeId
8+
import templates.SCRIPT_PATH
9+
import templates.TemplateSearchIndex
10+
import vcsRoots.KotlinLangOrg
11+
12+
private fun String.camelCase(delim: String = "-", join: String = "") =
13+
this.split(delim).joinToString(join) { it.replaceFirstChar { char -> char.uppercase() } }
14+
15+
typealias ProjectReferenceBuilder = () -> BuildType
16+
17+
open class ReferenceProject(val urlPart: String, val projectTitle: String = urlPart) {
18+
init {
19+
if (urlPart.isBlank()) throw IllegalArgumentException("urlPart cannot be blank")
20+
}
21+
22+
val projectName = projectTitle.camelCase(join = " ")
23+
val projectPrefix = urlPart.camelCase()
24+
25+
val project = Project {
26+
id = RelativeId(projectPrefix)
27+
name = projectName
28+
description = "Project for https://kotlinlang.org/api/$urlPart/"
29+
30+
params {
31+
param("env.ALGOLIA_INDEX_NAME", urlPart)
32+
param("env.API_REFERENCE_NAME", projectTitle)
33+
}
34+
}
35+
36+
val versions = mutableListOf<Pair<BuildType, String>>()
37+
38+
val currentVersion: BuildType
39+
get() = this.versions.lastOrNull()?.first
40+
?: throw IllegalStateException("Current version is not set for $projectName")
41+
42+
fun addReference(version: String, buildReference: ProjectReferenceBuilder) {
43+
versions.add(buildReference() to version)
44+
}
45+
46+
fun pagesSearchType(workingDir: String) = BuildType {
47+
id = RelativeId("${projectPrefix}_Latest")
48+
name = "API Pages"
49+
description = "The latest stable version for $projectName"
50+
artifactRules = "$workingDir/** => pages.zip"
51+
52+
vcs {
53+
root(KotlinLangOrg, "${SCRIPT_PATH}/")
54+
}
55+
56+
steps {
57+
step(scriptNoRobots(workingDir))
58+
step(scriptGenerateSitemap(workingDir))
59+
}
60+
61+
dependencies {
62+
dependency(currentVersion) {
63+
snapshot {}
64+
artifacts {
65+
artifactRules = "pages.zip!** => $workingDir"
66+
cleanDestination = true
67+
}
68+
}
69+
}
70+
}
71+
72+
fun searchBuildType(workingDir: String, pages: BuildType) = TemplateSearchIndex {
73+
id = RelativeId("${projectPrefix}_Search")
74+
name = "API Search Index"
75+
description = "Build search index for $projectName"
76+
77+
params {
78+
param("env.ALGOLIA_INDEX_NAME", urlPart)
79+
}
80+
81+
dependencies {
82+
dependency(pages) {
83+
snapshot {}
84+
artifacts {
85+
artifactRules = "pages.zip!** => $workingDir"
86+
cleanDestination = true
87+
}
88+
}
89+
}
90+
}
91+
92+
fun build() {
93+
val workingDir = "dist/api/$urlPart"
94+
val pages = pagesSearchType(workingDir)
95+
96+
project.apply {
97+
buildType(pages)
98+
buildType(searchBuildType(workingDir, pages))
99+
}
100+
101+
currentVersion.dependencies {
102+
for ((previousVersion, version) in versions) {
103+
if (previousVersion == currentVersion) continue
104+
artifacts(previousVersion) {
105+
buildRule = tag("release")
106+
artifactRules = "pages.zip!** => %OLD_VERSIONS_DIR%/$version/"
107+
cleanDestination = true
108+
}
109+
}
110+
}
111+
}
112+
}

.teamcity/common/extensions/index.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package common.extensions
2+
3+
object VCS {
4+
fun tag(name: String) = "refs/tags/$name"
5+
fun branch(name: String) = "refs/heads/$name"
6+
}

0 commit comments

Comments
 (0)