Skip to content

Commit 068b69d

Browse files
author
Abduqodiri Qurbonzoda
committed
Use KnownBuilds class to group access to created project configurations
1 parent f0514a9 commit 068b69d

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

.teamcity/additionalConfiguration.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
import jetbrains.buildServer.configs.kotlin.v2019_2.Project
77

88
fun Project.additionalConfiguration() {
9-
subProject(benchmarksProject(existingBuildVersion()))
9+
subProject(benchmarksProject(knownBuilds.buildVersion))
1010
}

.teamcity/utils.kt

+15-9
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,21 @@ const val BUILD_ALL_ID = "Build_All"
3737
const val DEPLOY_CONFIGURE_VERSION_ID = "Deploy_Configure"
3838
const val DEPLOY_PUBLISH_ID = "Deploy_Publish"
3939

40-
private fun existingBuildId(suffix: String): String = "RootProjectId_$suffix"
41-
private fun Project.existingBuildWithId(id: String): BuildType = buildTypes.single { it.id.toString() == existingBuildId(id) }
42-
43-
fun Project.existingBuildVersion(): BuildType = existingBuildWithId(BUILD_CONFIGURE_VERSION_ID)
44-
fun Project.existingBuildAll(): BuildType = existingBuildWithId(BUILD_ALL_ID)
45-
fun Project.existingBuild(platform: Platform): BuildType = existingBuildWithId("Build_${platform.buildTypeId()}")
46-
fun Project.existingDeployVersion(): BuildType = existingBuildWithId(DEPLOY_CONFIGURE_VERSION_ID)
47-
fun Project.existingDeployPublish(): BuildType = existingBuildWithId(DEPLOY_PUBLISH_ID)
48-
fun Project.existingDeploy(platform: Platform): BuildType = existingBuildWithId("Deploy_${platform.buildTypeId()}")
40+
class KnownBuilds(private val project: Project) {
41+
private fun buildWithId(id: String): BuildType {
42+
val fullId = "RootProjectId_$id"
43+
return project.buildTypes.single { it.id.toString() == fullId }
44+
}
45+
46+
val buildVersion: BuildType get() = buildWithId(BUILD_CONFIGURE_VERSION_ID)
47+
val buildAll: BuildType get() = buildWithId(BUILD_ALL_ID)
48+
fun buildOn(platform: Platform): BuildType = buildWithId("Build_${platform.buildTypeId()}")
49+
val deployVersion: BuildType get() = buildWithId(DEPLOY_CONFIGURE_VERSION_ID)
50+
val deployPublish: BuildType get() = buildWithId(DEPLOY_PUBLISH_ID)
51+
fun deployOn(platform: Platform): BuildType = buildWithId("Deploy_${platform.buildTypeId()}")
52+
}
53+
54+
val Project.knownBuilds: KnownBuilds get() = KnownBuilds(this)
4955

5056

5157
fun Project.buildType(name: String, platform: Platform, configure: BuildType.() -> Unit) = BuildType {

0 commit comments

Comments
 (0)