|
| 1 | + |
1 | 2 | package subprojects.train |
2 | 3 |
|
3 | 4 | import jetbrains.buildServer.configs.kotlin.* |
@@ -101,6 +102,49 @@ interface EAPSampleConfig { |
101 | 102 | } |
102 | 103 |
|
103 | 104 | fun BuildSteps.createEAPGradleInitScript() { |
| 105 | + script { |
| 106 | + name = "Create EAP Gradle init script" |
| 107 | + executionMode = BuildStep.ExecutionMode.ALWAYS |
| 108 | + scriptContent = """ |
| 109 | + mkdir -p %system.teamcity.build.tempDir% |
| 110 | + |
| 111 | + echo "Using Ktor Framework EAP version: %env.KTOR_VERSION%" |
| 112 | + |
| 113 | + cat > %system.teamcity.build.tempDir%/ktor-eap.init.gradle.kts << 'EOF' |
| 114 | +gradle.allprojects { |
| 115 | + repositories { |
| 116 | + ${EapRepositoryConfig.generateGradleRepositories()} |
| 117 | + } |
| 118 | + |
| 119 | + configurations.all { |
| 120 | + resolutionStrategy { |
| 121 | + eachDependency { |
| 122 | + if (requested.group == "io.ktor") { |
| 123 | + val ktorVersion = System.getenv("KTOR_VERSION") |
| 124 | + if (ktorVersion.isNullOrBlank()) { |
| 125 | + throw GradleException("KTOR_VERSION environment variable is not set or is blank. Cannot resolve Ktor EAP dependencies.") |
| 126 | + } |
| 127 | + useVersion(ktorVersion) |
| 128 | + logger.lifecycle("Forcing Ktor dependency " + requested.name + " to use EAP version: " + ktorVersion) |
| 129 | + } |
| 130 | + } |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + afterEvaluate { |
| 135 | + if (this == rootProject) { |
| 136 | + val frameworkVersion = System.getenv("KTOR_VERSION") |
| 137 | + logger.lifecycle("Project " + name + ": Using Ktor Framework EAP version: " + frameworkVersion) |
| 138 | + logger.lifecycle("Project " + name + ": EAP repository configured for framework") |
| 139 | + } |
| 140 | + } |
| 141 | +} |
| 142 | +EOF |
| 143 | + """.trimIndent() |
| 144 | + } |
| 145 | +} |
| 146 | + |
| 147 | +fun BuildSteps.createEAPGradlePluginInitScript() { |
104 | 148 | script { |
105 | 149 | name = "Detect EAP Plugin Version" |
106 | 150 | executionMode = BuildStep.ExecutionMode.ALWAYS |
@@ -168,7 +212,7 @@ fun BuildSteps.createEAPGradleInitScript() { |
168 | 212 | } |
169 | 213 |
|
170 | 214 | script { |
171 | | - name = "Create EAP Gradle init script" |
| 215 | + name = "Create EAP Gradle Plugin init script" |
172 | 216 | executionMode = BuildStep.ExecutionMode.RUN_ON_SUCCESS |
173 | 217 | scriptContent = """ |
174 | 218 | mkdir -p %system.teamcity.build.tempDir% |
@@ -366,7 +410,7 @@ fun BuildSteps.buildEAPGradleSample(relativeDir: String, standalone: Boolean) { |
366 | 410 | } |
367 | 411 |
|
368 | 412 | fun BuildSteps.buildEAPGradlePluginSample(relativeDir: String, standalone: Boolean) { |
369 | | - createEAPGradleInitScript() |
| 413 | + createEAPGradlePluginInitScript() |
370 | 414 |
|
371 | 415 | if (!standalone) { |
372 | 416 | modifyRootSettingsForEAP() |
@@ -475,10 +519,11 @@ fun BuildSteps.buildEAPMavenSample(relativeDir: String) { |
475 | 519 | executionMode = BuildStep.ExecutionMode.ALWAYS |
476 | 520 | scriptContent = """ |
477 | 521 | # Validate KTOR_VERSION is available for EAP Maven sample |
478 | | - if [ -z "%env.KTOR_VERSION%" ]; then |
479 | | - echo "ERROR: KTOR_VERSION is required for EAP Maven sample but not set" |
480 | | - exit 1 |
481 | | - fi |
| 522 | + if [ -z "%env.KTOR_VERSION%" ]; then |
| 523 | + echo "ERROR: KTOR_VERSION is required for EAP Maven sample but not set" |
| 524 | + exit 1 |
| 525 | + fi |
| 526 | + |
482 | 527 | mkdir -p %system.teamcity.build.tempDir%/.m2 |
483 | 528 | |
484 | 529 | cat > %system.teamcity.build.tempDir%/.m2/settings.xml << EOF |
|
0 commit comments