@@ -19,19 +19,29 @@ version = run {
1919 val tcCounter = System .getenv(" TC_BUILD_COUNTER" )
2020
2121 if (releaseBuild) {
22- if (branch == " main" ) {
23- if (customVersion.isNullOrBlank()) {
24- " "
25- } else {
26- throw GradleException (" Custom version is not allowed during release from the main branch" )
22+ when (branch) {
23+ " main" -> {
24+ if (customVersion.isNullOrBlank()) {
25+ " "
26+ } else {
27+ throw GradleException (" Custom version is not allowed during release from the main branch" )
28+ }
2729 }
28- } else {
29- if (! customVersion.isNullOrBlank()) {
30- " -feat-$customVersion " // todo check for develop
31- } else if (branch == " develop" && ! tcCounter.isNullOrBlank()) {
32- " .$tcCounter "
33- } else {
34- throw GradleException (" Custom version is required during release from the non-main branch" )
30+ " develop" -> {
31+ if (! customVersion.isNullOrBlank()) {
32+ throw GradleException (" Custom version is not allowed during release from the develop branch" )
33+ } else if (tcCounter.isNullOrBlank()) {
34+ throw GradleException (" TC_BUILD_COUNTER is required during release from the develop branch" )
35+ } else {
36+ " .$tcCounter "
37+ }
38+ }
39+ else -> {
40+ if (! customVersion.isNullOrBlank()) {
41+ " -feat-$customVersion "
42+ } else {
43+ throw GradleException (" Custom version is required during release from a feature branch" )
44+ }
3545 }
3646 }
3747 } else {
@@ -86,7 +96,7 @@ subprojects {
8696 }
8797}
8898
89- task (" reportProjectVersionToTeamCity" ) {
99+ tasks.register (" reportProjectVersionToTeamCity" ) {
90100 doLast {
91101 println (" ##teamcity[buildNumber '${project.version} ']" )
92102 }
@@ -105,6 +115,7 @@ tasks {
105115 destinationDirectory.set(layout.buildDirectory)
106116 }
107117
118+ @Suppress(" unused" )
108119 val publishMavenToCentralPortal by registering {
109120 group = " publishing"
110121
0 commit comments