-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle.kts
179 lines (153 loc) · 5.62 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import java.io.FileInputStream
import com.github.jk1.license.render.*
import com.github.jk1.license.filter.*
import java.nio.file.Path
import java.nio.file.Paths
import java.util.*
plugins {
kotlin("jvm") version "1.9.22"
id("com.github.rodm.teamcity-server") version "1.5.2"
id("com.github.rodm.teamcity-environments") version "1.5.2"
id ("com.github.jk1.dependency-license-report") version "2.5"
}
initializeWorkspace()
group = "org.jetbrains.teamcity"
val pluginVersion = anyParam("PluginVersion") ?: "999999-snapshot-${Date().time}"
version = pluginVersion
val teamcityVersion = anyParam("teamcityVersion") ?: "2023.11-SNAPSHOT"
val spacePackagesToken = anyParam("spacePackagesToken")
val spacePackagesUsername = anyParam("spacePackagesUsername")
val spacePackagesPassword = anyParam("spacePackagesPassword")
val canDownloadSpacePackages = spacePackagesToken != null ||
(spacePackagesUsername != null && spacePackagesPassword != null)
val localRepo = anyParamPath("TC_LOCAL_REPO")
if (!canDownloadSpacePackages) {
println("Not running integration tests, can't authorize to Space")
}
extra["teamcityVersion"] = teamcityVersion
extra["downloadsDir"] = anyParam("downloads.dir") ?: "${rootDir}/downloads"
extra["canDownloadSpacePackages"] = canDownloadSpacePackages
allprojects {
repositories {
if (localRepo != null) {
maven(url = "file:///${localRepo}")
}
mavenLocal()
maven(url = "https://cache-redirector.jetbrains.com/maven-central")
maven(url = "https://download.jetbrains.com/teamcity-repository")
maven(url = "https://repo.labs.intellij.net/teamcity")
mavenCentral()
if (canDownloadSpacePackages) {
maven(url = "https://packages.jetbrains.team/maven/p/tc/maven") {
if (spacePackagesToken != null) {
credentials(HttpHeaderCredentials::class) {
name = "Authorization"
value = "Bearer $spacePackagesToken"
}
authentication {
create<HttpHeaderAuthentication>("header")
}
} else {
credentials {
username = spacePackagesUsername
password = spacePackagesPassword
}
}
}
}
}
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3") {
exclude("com.fasterxml.jackson.core", "jackson-annotations")
exclude("com.fasterxml.jackson.core", "jackson-databind")
}
implementation("com.google.code.gson:gson:2.9.0")
implementation("com.github.salomonbrys.kotson:kotson:2.5.0")
implementation("com.github.ben-manes.caffeine:caffeine:2.9.2")
provided("org.jetbrains.teamcity:server-api:${teamcityVersion}")
provided("org.jetbrains.teamcity:oauth:${teamcityVersion}")
provided("org.jetbrains.teamcity:web-openapi:${teamcityVersion}")
provided("org.jetbrains.teamcity.internal:server:${teamcityVersion}")
provided("org.jetbrains.teamcity.internal:web:${teamcityVersion}")
provided("com.ibm.icu:icu4j:4.8.1.1")
testImplementation("org.assertj:assertj-core:1.7.1")
testImplementation("org.testng:testng:6.8")
testImplementation("io.mockk:mockk:1.10.0")
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
teamcity {
version = "2022.10"
server {
archiveName = "slack.zip"
descriptor = file("teamcity-plugin.xml")
tokens = mapOf("Version" to pluginVersion)
files {
into("kotlin-dsl") {
from("src/kotlin-dsl")
}
}
}
}
licenseReport {
renderers = arrayOf(JsonReportRenderer("third-party-libraries.json"))
excludes = arrayOf("org.jetbrains.*", "com.jetbrains.*", ".*jackson-bom*")
filters = arrayOf<DependencyFilter>(
LicenseBundleNormalizer("${project.rootDir}/license-third-party-normalizer.json", false)
)
}
tasks.serverPlugin {
finalizedBy(project.tasks.getByName("generateLicenseReport"))
}
fun anyParamPath(vararg names: String): Path? {
val param = anyParam(*names)
if (param == null || param.isEmpty())
return null
return if (Paths.get(param).isAbsolute()) {
Paths.get(param)
} else {
getRootDir().toPath().resolve(param)
}
}
fun anyParam(vararg names: String): String? {
var param: String? = ""
try {
for(name in names) {
param = if (project.hasProperty(name)) {
project.property(name).toString()
} else {
System.getProperty(name) ?: System.getenv(name) ?: null
}
if (param != null)
break;
}
if (param == null || param.isEmpty())
param = null
} finally {
println("AnyParam: ${names.joinToString(separator = ",")} -> $param")
}
return param
}
fun initializeWorkspace() {
if (System.getProperty("idea.active") != null) {
println("Attempt to configure workspace in IDEA")
val coreVersionProperties = project.projectDir.toPath().parent.parent.resolve(".version.properties")
if (coreVersionProperties.toFile().exists()) {
val p = Properties().also {
it.load(FileInputStream(coreVersionProperties.toFile()))
}
p.forEach {(k,v) ->
System.setProperty(k.toString(), v.toString());
}
}
}
}