Skip to content

Commit 2ba84a6

Browse files
Elena LepilkinaElena Lepilkina
Elena Lepilkina
authored and
Elena Lepilkina
committed
Updated versions and teamcity settings for 0.3.3 version release
1 parent 544e09e commit 2ba84a6

File tree

7 files changed

+172
-113
lines changed

7 files changed

+172
-113
lines changed

.teamcity/additionalConfiguration.kt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
import jetbrains.buildServer.configs.kotlin.v2019_2.Project
7+
8+
fun Project.additionalConfiguration() {
9+
}

.teamcity/settings.kts

+30-92
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import jetbrains.buildServer.configs.kotlin.v2018_2.*
2-
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.*
3-
import jetbrains.buildServer.configs.kotlin.v2018_2.triggers.*
1+
import jetbrains.buildServer.configs.kotlin.v2019_2.*
2+
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.*
3+
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.*
44

55
/*
66
The settings script is an entry point for defining a TeamCity
@@ -24,16 +24,7 @@ To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
2424
'Debug' option is available in the context menu for the task.
2525
*/
2626

27-
version = "2018.2"
28-
val versionSuffixParameter = "versionSuffix"
29-
val teamcitySuffixParameter = "teamcitySuffix"
30-
val releaseVersionParameter = "releaseVersion"
31-
32-
val bintrayUserName = "%env.BINTRAY_USER%"
33-
val bintrayToken = "%env.BINTRAY_API_KEY%"
34-
35-
val platforms = listOf("Windows", "Linux", "Mac OS X")
36-
val jdk = "JDK_18_x64"
27+
version = "2020.1"
3728

3829
project {
3930
// Disable editing of project and build settings from the UI to avoid issues with TeamCity
@@ -53,22 +44,30 @@ project {
5344
}
5445
}
5546

56-
val deployConfigure = deployConfigure().apply {
47+
val deployVersion = deployVersion().apply {
5748
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
49+
dependsOnSnapshot(BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID) {
50+
reuseBuilds = ReuseBuilds.NO
51+
}
5852
}
59-
val deploys = platforms.map { deploy(it, deployConfigure) }
60-
val deployPublish = deployPublish(deployConfigure).apply {
53+
val deploys = platforms.map { deploy(it, deployVersion) }
54+
val deployPublish = deployPublish(deployVersion).apply {
6155
dependsOnSnapshot(buildAll, onFailure = FailureAction.IGNORE)
56+
dependsOnSnapshot(BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID) {
57+
reuseBuilds = ReuseBuilds.NO
58+
}
6259
deploys.forEach {
6360
dependsOnSnapshot(it)
6461
}
6562
}
6663

67-
buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployConfigure, *deploys.toTypedArray())
64+
buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployVersion, *deploys.toTypedArray())
65+
66+
additionalConfiguration()
6867
}
6968

7069
fun Project.buildVersion() = BuildType {
71-
id("Build_Version")
70+
id(BUILD_CONFIGURE_VERSION_ID)
7271
this.name = "Build (Configure Version)"
7372
commonConfigure()
7473

@@ -90,7 +89,7 @@ fun Project.buildVersion() = BuildType {
9089
}.also { buildType(it) }
9190

9291
fun Project.buildAll(versionBuild: BuildType) = BuildType {
93-
id("Build_All")
92+
id(BUILD_ALL_ID)
9493
this.name = "Build (All)"
9594
type = BuildTypeSettings.Type.COMPOSITE
9695

@@ -109,7 +108,7 @@ fun Project.buildAll(versionBuild: BuildType) = BuildType {
109108
commonConfigure()
110109
}.also { buildType(it) }
111110

112-
fun Project.build(platform: String, versionBuild: BuildType) = platform(platform, "Build") {
111+
fun Project.build(platform: Platform, versionBuild: BuildType) = buildType("Build", platform) {
113112

114113
dependsOnSnapshot(versionBuild)
115114

@@ -120,7 +119,7 @@ fun Project.build(platform: String, versionBuild: BuildType) = platform(platform
120119

121120
steps {
122121
gradle {
123-
name = "Build and Test $platform Binaries"
122+
name = "Build and Test ${platform.buildTypeName()} Binaries"
124123
jdkHome = "%env.$jdk%"
125124
jvmArgs = "-Xmx1g"
126125
tasks = "clean publishToBuildLocal check"
@@ -135,23 +134,8 @@ fun Project.build(platform: String, versionBuild: BuildType) = platform(platform
135134
artifactRules = "+:build/maven=>maven\n+:build/api=>api"
136135
}
137136

138-
fun BuildType.dependsOn(build: BuildType, configure: Dependency.() -> Unit) =
139-
apply {
140-
dependencies.dependency(build, configure)
141-
}
142-
143-
fun BuildType.dependsOnSnapshot(build: BuildType, onFailure: FailureAction = FailureAction.FAIL_TO_START, configure: SnapshotDependency.() -> Unit = {}) = apply {
144-
dependencies.dependency(build) {
145-
snapshot {
146-
configure()
147-
onDependencyFailure = onFailure
148-
onDependencyCancel = FailureAction.CANCEL
149-
}
150-
}
151-
}
152-
153-
fun Project.deployConfigure() = BuildType {
154-
id("Deploy_Configure")
137+
fun Project.deployVersion() = BuildType {
138+
id(DEPLOY_CONFIGURE_VERSION_ID)
155139
this.name = "Deploy (Configure Version)"
156140
commonConfigure()
157141

@@ -161,6 +145,8 @@ fun Project.deployConfigure() = BuildType {
161145
param("bintray-user", bintrayUserName)
162146
password("bintray-key", bintrayToken)
163147
param(versionSuffixParameter, "dev-%build.counter%")
148+
param("reverse.dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.system.libs.repo.description", libraryStagingRepoDescription)
149+
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
164150
}
165151

166152
requirements {
@@ -171,7 +157,7 @@ fun Project.deployConfigure() = BuildType {
171157
steps {
172158
gradle {
173159
name = "Verify Gradle Configuration"
174-
tasks = "clean publishBintrayCreateVersion"
160+
tasks = "clean publishPrepareVersion"
175161
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter% -PbintrayApiKey=%bintray-key% -PbintrayUser=%bintray-user%"
176162
buildFile = ""
177163
jdkHome = "%env.$jdk%"
@@ -180,7 +166,7 @@ fun Project.deployConfigure() = BuildType {
180166
}.also { buildType(it) }
181167

182168
fun Project.deployPublish(configureBuild: BuildType) = BuildType {
183-
id("Deploy_Publish")
169+
id(DEPLOY_PUBLISH_ID)
184170
this.name = "Deploy (Publish)"
185171
type = BuildTypeSettings.Type.COMPOSITE
186172
dependsOnSnapshot(configureBuild)
@@ -189,12 +175,13 @@ fun Project.deployPublish(configureBuild: BuildType) = BuildType {
189175
// Tell configuration build how to get release version parameter from this build
190176
// "dev" is the default and means publishing is not releasing to public
191177
text(configureBuild.reverseDepParamRefs[releaseVersionParameter].name, "dev", display = ParameterDisplay.PROMPT, label = "Release Version")
178+
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
192179
}
193180
commonConfigure()
194181
}.also { buildType(it) }
195182

196183

197-
fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platform, "Deploy") {
184+
fun Project.deploy(platform: Platform, configureBuild: BuildType) = buildType("Deploy", platform) {
198185
type = BuildTypeSettings.Type.DEPLOYMENT
199186
enablePersonalBuilds = false
200187
maxRunningBuilds = 1
@@ -203,6 +190,7 @@ fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platf
203190
param(releaseVersionParameter, "${configureBuild.depParamRefs[releaseVersionParameter]}")
204191
param("bintray-user", bintrayUserName)
205192
password("bintray-key", bintrayToken)
193+
param("env.libs.repository.id", "%dep.$BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID.env.libs.repository.id%")
206194
}
207195

208196
vcs {
@@ -211,7 +199,7 @@ fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platf
211199

212200
steps {
213201
gradle {
214-
name = "Deploy $platform Binaries"
202+
name = "Deploy ${platform.buildTypeName()} Binaries"
215203
jdkHome = "%env.$jdk%"
216204
jvmArgs = "-Xmx1g"
217205
gradleParams = "--info --stacktrace -P$versionSuffixParameter=%$versionSuffixParameter% -P$releaseVersionParameter=%$releaseVersionParameter% -PbintrayApiKey=%bintray-key% -PbintrayUser=%bintray-user%"
@@ -221,53 +209,3 @@ fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platf
221209
}
222210
}
223211
}.dependsOnSnapshot(configureBuild)
224-
225-
fun Project.platform(platform: String, name: String, configure: BuildType.() -> Unit) = BuildType {
226-
// ID is prepended with Project ID, so don't repeat it here
227-
// ID should conform to identifier rules, so just letters, numbers and underscore
228-
id("${name}_${platform.substringBefore(" ")}")
229-
// Display name of the build configuration
230-
this.name = "$name ($platform)"
231-
232-
requirements {
233-
contains("teamcity.agent.jvm.os.name", platform)
234-
}
235-
236-
params {
237-
// This parameter is needed for macOS agent to be compatible
238-
if (platform.startsWith("Mac")) param("env.JDK_17", "")
239-
}
240-
241-
commonConfigure()
242-
configure()
243-
}.also { buildType(it) }
244-
245-
246-
fun BuildType.commonConfigure() {
247-
requirements {
248-
noLessThan("teamcity.agent.hardware.memorySizeMb", "6144")
249-
}
250-
251-
// Allow to fetch build status through API for badges
252-
allowExternalStatus = true
253-
254-
// Configure VCS, by default use the same and only VCS root from which this configuration is fetched
255-
vcs {
256-
root(DslContext.settingsRoot)
257-
showDependenciesChanges = true
258-
checkoutMode = CheckoutMode.ON_AGENT
259-
}
260-
261-
failureConditions {
262-
errorMessage = true
263-
nonZeroExitCode = true
264-
executionTimeoutMin = 120
265-
}
266-
267-
features {
268-
feature {
269-
id = "perfmon"
270-
type = "perfmon"
271-
}
272-
}
273-
}

.teamcity/utils.kt

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
import jetbrains.buildServer.configs.kotlin.v2019_2.*
7+
8+
const val versionSuffixParameter = "versionSuffix"
9+
const val teamcitySuffixParameter = "teamcitySuffix"
10+
const val releaseVersionParameter = "releaseVersion"
11+
12+
const val bintrayUserName = "%env.BINTRAY_USER%"
13+
const val bintrayToken = "%env.BINTRAY_API_KEY%"
14+
const val libraryStagingRepoDescription = "Kotlinx-Cli-Library"
15+
16+
val platforms = Platform.values()
17+
const val jdk = "JDK_18_x64"
18+
19+
enum class Platform {
20+
Windows, Linux, MacOS;
21+
}
22+
23+
fun Platform.nativeTaskPrefix(): String = when(this) {
24+
Platform.Windows -> "mingwX64"
25+
Platform.Linux -> "linuxX64"
26+
Platform.MacOS -> "macosX64"
27+
}
28+
fun Platform.buildTypeName(): String = when (this) {
29+
Platform.Windows, Platform.Linux -> name
30+
Platform.MacOS -> "Mac OS X"
31+
}
32+
fun Platform.buildTypeId(): String = buildTypeName().substringBefore(" ")
33+
fun Platform.teamcityAgentName(): String = buildTypeName()
34+
35+
36+
const val BUILD_CONFIGURE_VERSION_ID = "Build_Version"
37+
const val BUILD_ALL_ID = "Build_All"
38+
const val DEPLOY_CONFIGURE_VERSION_ID = "Deploy_Configure"
39+
const val DEPLOY_PUBLISH_ID = "Deploy_Publish"
40+
41+
val BUILD_CREATE_STAGING_REPO_ABSOLUTE_ID = AbsoluteId("KotlinTools_CreateSonatypeStagingRepository")
42+
43+
class KnownBuilds(private val project: Project) {
44+
private fun buildWithId(id: String): BuildType {
45+
return project.buildTypes.single { it.id.toString().endsWith(id) }
46+
}
47+
48+
val buildVersion: BuildType get() = buildWithId(BUILD_CONFIGURE_VERSION_ID)
49+
val buildAll: BuildType get() = buildWithId(BUILD_ALL_ID)
50+
fun buildOn(platform: Platform): BuildType = buildWithId("Build_${platform.buildTypeId()}")
51+
val deployVersion: BuildType get() = buildWithId(DEPLOY_CONFIGURE_VERSION_ID)
52+
val deployPublish: BuildType get() = buildWithId(DEPLOY_PUBLISH_ID)
53+
fun deployOn(platform: Platform): BuildType = buildWithId("Deploy_${platform.buildTypeId()}")
54+
}
55+
56+
val Project.knownBuilds: KnownBuilds get() = KnownBuilds(this)
57+
58+
59+
fun Project.buildType(name: String, platform: Platform, configure: BuildType.() -> Unit) = BuildType {
60+
// ID is prepended with Project ID, so don't repeat it here
61+
// ID should conform to identifier rules, so just letters, numbers and underscore
62+
id("${name}_${platform.buildTypeId()}")
63+
// Display name of the build configuration
64+
this.name = "$name (${platform.buildTypeName()})"
65+
66+
requirements {
67+
contains("teamcity.agent.jvm.os.name", platform.teamcityAgentName())
68+
}
69+
70+
params {
71+
// This parameter is needed for macOS agent to be compatible
72+
if (platform == Platform.MacOS) param("env.JDK_17", "")
73+
}
74+
75+
commonConfigure()
76+
configure()
77+
}.also { buildType(it) }
78+
79+
80+
fun BuildType.commonConfigure() {
81+
requirements {
82+
noLessThan("teamcity.agent.hardware.memorySizeMb", "6144")
83+
}
84+
85+
// Allow to fetch build status through API for badges
86+
allowExternalStatus = true
87+
88+
// Configure VCS, by default use the same and only VCS root from which this configuration is fetched
89+
vcs {
90+
root(DslContext.settingsRoot)
91+
showDependenciesChanges = true
92+
checkoutMode = CheckoutMode.ON_AGENT
93+
}
94+
95+
failureConditions {
96+
errorMessage = true
97+
nonZeroExitCode = true
98+
executionTimeoutMin = 120
99+
}
100+
101+
features {
102+
feature {
103+
id = "perfmon"
104+
type = "perfmon"
105+
}
106+
}
107+
}
108+
109+
fun BuildType.dependsOn(build: IdOwner, configure: Dependency.() -> Unit) =
110+
apply {
111+
dependencies.dependency(build, configure)
112+
}
113+
114+
fun BuildType.dependsOnSnapshot(build: IdOwner, onFailure: FailureAction = FailureAction.FAIL_TO_START, configure: SnapshotDependency.() -> Unit = {}) = apply {
115+
dependencies.dependency(build) {
116+
snapshot {
117+
configure()
118+
onDependencyFailure = onFailure
119+
onDependencyCancel = FailureAction.CANCEL
120+
}
121+
}
122+
}

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.3 ##
2+
3+
* Fix to report correct exit code in case of non-parsable input ([GH-66](https://github.com/Kotlin/kotlinx-cli/pull/66))
4+
15
## 0.3.2 ##
26

37
* Added option to strict order of subcommands and their parameters([GH-55](https://github.com/Kotlin/kotlinx-cli/pull/55))

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ kotlin {
3939
sourceSets {
4040
commonMain {
4141
dependencies {
42-
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.2")
42+
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.3")
4343
}
4444
}
4545
}
@@ -70,7 +70,7 @@ In Kotlin projects, add the following dependency to the `dependencies` element o
7070
<dependency>
7171
<groupId>org.jetbrains.kotlinx</groupId>
7272
<artifactId>kotlinx-cli-jvm</artifactId>
73-
<version>0.3.2</version>
73+
<version>0.3.3</version>
7474
</dependency>
7575
```
7676
## Command line entities

0 commit comments

Comments
 (0)