@@ -6,6 +6,7 @@ import jetbrains.buildServer.configs.kotlin.BuildType
6
6
import jetbrains.buildServer.configs.kotlin.Project
7
7
import jetbrains.buildServer.configs.kotlin.RelativeId
8
8
import templates.SCRIPT_PATH
9
+ import templates.TemplateSearchIndex
9
10
import vcsRoots.KotlinLangOrg
10
11
11
12
private fun String.camelCase (delim : String = "-", join : String = "") =
@@ -19,8 +20,8 @@ open class ReferenceProject(val urlPart: String, val projectTitle: String = urlP
19
20
}
20
21
21
22
val projectName = projectTitle.camelCase(join = " " )
22
-
23
23
val projectPrefix = urlPart.camelCase()
24
+
24
25
val project = Project {
25
26
id = RelativeId (projectPrefix)
26
27
name = projectName
@@ -32,64 +33,69 @@ open class ReferenceProject(val urlPart: String, val projectTitle: String = urlP
32
33
}
33
34
}
34
35
35
- protected val versions = mutableListOf<Pair <BuildType , String >>()
36
+ val versions = mutableListOf<Pair <BuildType , String >>()
36
37
37
- fun getCurrentVersion (): Pair <BuildType , String >? = this .versions.lastOrNull()
38
+ val currentVersion: BuildType
39
+ get() = this .versions.lastOrNull()?.first
40
+ ? : throw IllegalStateException (" Current version is not set for $projectName " )
38
41
39
42
fun addReference (version : String , buildReference : ProjectReferenceBuilder ) {
40
43
versions.add(buildReference() to version)
41
44
}
42
45
43
- fun build () {
44
- val (currentVersion) = getCurrentVersion( )
45
- ? : throw IllegalStateException ( " Current version is not set for $projectName " )
46
-
47
- val workingDir = " dist/api/ $urlPart "
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 "
48
51
49
- val pages = BuildType {
50
- id = RelativeId (" ${projectPrefix} _Latest" )
51
- name = " API Pages"
52
- description = " The latest stable version for $projectName "
52
+ vcs {
53
+ root(KotlinLangOrg , " ${SCRIPT_PATH } /" )
54
+ }
53
55
54
- artifactRules = " $workingDir /** => pages.zip"
56
+ steps {
57
+ step(scriptNoRobots(workingDir))
58
+ step(scriptGenerateSitemap(workingDir))
59
+ }
55
60
56
- vcs {
57
- root(KotlinLangOrg , " ${SCRIPT_PATH } /" )
61
+ dependencies {
62
+ dependency(currentVersion) {
63
+ snapshot {}
64
+ artifacts {
65
+ artifactRules = " pages.zip!** => $workingDir "
66
+ cleanDestination = true
67
+ }
58
68
}
69
+ }
70
+ }
59
71
60
- steps {
61
- step(scriptNoRobots(workingDir))
62
- step(scriptGenerateSitemap(workingDir))
63
- }
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
+ }
64
80
65
- dependencies {
66
- dependency(currentVersion) {
67
- snapshot {}
68
- artifacts {
69
- artifactRules = " pages.zip!** => $workingDir "
70
- cleanDestination = true
71
- }
81
+ dependencies {
82
+ dependency(pages) {
83
+ snapshot {}
84
+ artifacts {
85
+ artifactRules = " pages.zip!** => $workingDir "
86
+ cleanDestination = true
72
87
}
73
88
}
74
89
}
90
+ }
91
+
92
+ fun build () {
93
+ val workingDir = " dist/api/$urlPart "
94
+ val pages = pagesSearchType(workingDir)
75
95
76
96
project.apply {
77
97
buildType(pages)
78
- buildType {
79
- id = RelativeId (" ${projectPrefix} _Search" )
80
- name = " API Search Index"
81
- description = " Build search index for $projectName "
82
-
83
- dependencies {
84
- dependency(pages) {
85
- snapshot {}
86
- artifacts {
87
- artifactRules = " pages.zip!** => $workingDir "
88
- cleanDestination = true
89
- }
90
- }
91
- }
92
- }
98
+ buildType(searchBuildType(workingDir, pages))
93
99
}
94
100
95
101
currentVersion.dependencies {
0 commit comments