Skip to content

Commit fc6ef0d

Browse files
Abduqodiri Qurbonzodaqurbonzoda
authored andcommitted
Remove redundant <<PROJECT_NAME>> and <<PROJECT_VERSION>> insertions
1 parent 2c12f43 commit fc6ef0d

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

main/src/kotlinx/team/infra/TeamCity.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package kotlinx.team.infra
22

33
import org.gradle.api.*
4-
import org.gradle.api.plugins.*
54
import java.io.*
65

76
class TeamCityConfiguration {
8-
var projectName: String? = null
97
var bintrayUser: String? = null
108
var bintrayToken: String? = null
119

@@ -25,7 +23,6 @@ fun Project.configureTeamCityLogging() {
2523
}
2624

2725
fun Project.configureTeamCityConfigGenerator(teamcity: TeamCityConfiguration) {
28-
val project = this
2926
task<DefaultTask>("setupTeamCity") {
3027
group = "build setup"
3128
description = "Generates TeamCity project build configuration scripts"
@@ -38,15 +35,11 @@ fun Project.configureTeamCityConfigGenerator(teamcity: TeamCityConfiguration) {
3835
.replace("<artifactId>resource</artifactId>", "<artifactId>teamcity</artifactId>")
3936
}
4037
copyResource(teamcityDir, "settings.kts") { text ->
41-
val projectName = teamcity.projectName ?: project.name.removeSuffix("-package")
42-
val projectVersion = project.version.toString()
4338
val bintrayUser = teamcity.bintrayUser
4439
?: throw KotlinInfrastructureException("TeamCity configuration should specify `bintrayUser` parameter")
4540
val bintrayToken = teamcity.bintrayToken
4641
?: throw KotlinInfrastructureException("TeamCity configuration should specify `bintrayToken` parameter")
4742
text
48-
.replace("<<PROJECT_VERSION>>", projectVersion)
49-
.replace("<<PROJECT_NAME>>", projectName)
5043
.replace("<<BINTRAY_USER>>", bintrayUser)
5144
.replace("<<BINTRAY_TOKEN>>", bintrayToken)
5245
.replace("<<JDK>>", teamcity.jdk)
@@ -55,13 +48,16 @@ fun Project.configureTeamCityConfigGenerator(teamcity: TeamCityConfiguration) {
5548
}
5649
}
5750

58-
private inline fun copyResource(teamcityDir: File, file: String, transform: (String) -> String = { it }) {
51+
private inline fun copyResource(teamcityDir: File, file: String, override: Boolean = true, transform: (String) -> String = { it }) {
5952
val resource = InfraPlugin::class.java.getResourceAsStream("/teamcity/$file")
6053
?: throw KotlinInfrastructureException("Cannot find resource for teamcity file $file")
54+
val destinationFile = teamcityDir.resolve(file)
55+
56+
if (!override && destinationFile.exists()) return
6157

6258
resource.bufferedReader().use { input ->
6359
val text = input.readText().let(transform)
64-
teamcityDir.resolve(file).writeText(text)
60+
destinationFile.writeText(text)
6561
}
6662
}
6763

0 commit comments

Comments
 (0)