forked from JetBrains/koog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
231 lines (204 loc) · 8.3 KB
/
build.gradle.kts
File metadata and controls
231 lines (204 loc) · 8.3 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import ai.koog.gradle.fixups.DisableDistTasks.disableDistTasks
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.asRequestBody
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import java.util.*
group = "ai.koog"
version = run {
// our version follows the semver specification
val main = "0.2.1"
val feat = run {
val releaseBuild = !System.getenv("BRANCH_KOOG_IS_RELEASING_FROM").isNullOrBlank()
val branch = System.getenv("BRANCH_KOOG_IS_RELEASING_FROM")
val customVersion = System.getenv("CE_CUSTOM_VERSION")
val tcCounter = System.getenv("TC_BUILD_COUNTER")
if (releaseBuild) {
when (branch) {
"main" -> {
if (customVersion.isNullOrBlank()) {
""
} else {
throw GradleException("Custom version is not allowed during release from the main branch")
}
}
"develop" -> {
if (!customVersion.isNullOrBlank()) {
throw GradleException("Custom version is not allowed during release from the develop branch")
} else if (tcCounter.isNullOrBlank()) {
throw GradleException("TC_BUILD_COUNTER is required during release from the develop branch")
} else {
".$tcCounter"
}
}
else -> {
if (!customVersion.isNullOrBlank()) {
"-feat-$customVersion"
} else {
throw GradleException("Custom version is required during release from a feature branch")
}
}
}
} else {
// do not care
""
}
}
"$main$feat"
}
buildscript {
dependencies {
classpath("com.squareup.okhttp3:okhttp:4.12.0")
}
}
plugins {
id("ai.kotlin.dokka")
alias(libs.plugins.kotlinx.kover)
}
allprojects {
repositories {
mavenCentral()
}
}
disableDistTasks()
// Apply Kover to all subprojects
subprojects {
apply(plugin = "org.jetbrains.kotlinx.kover")
}
subprojects {
tasks.withType<Test> {
testLogging {
showStandardStreams = true
showExceptions = true
exceptionFormat = FULL
}
environment.putAll(
mapOf(
"ANTHROPIC_API_TEST_KEY" to System.getenv("ANTHROPIC_API_TEST_KEY"),
"OPEN_AI_API_TEST_KEY" to System.getenv("OPEN_AI_API_TEST_KEY"),
"GEMINI_API_TEST_KEY" to System.getenv("GEMINI_API_TEST_KEY"),
"OPEN_ROUTER_API_TEST_KEY" to System.getenv("OPEN_ROUTER_API_TEST_KEY"),
"AWS_SECRET_KEY" to System.getenv("AWS_SECRET_KEY"),
"AWS_ACCESS_KEY_ID" to System.getenv("AWS_ACCESS_KEY_ID"),
)
)
}
}
tasks.register("reportProjectVersionToTeamCity") {
doLast {
println("##teamcity[buildNumber '${project.version}']")
}
}
tasks {
val packSonatypeCentralBundle by registering(Zip::class) {
group = "publishing"
subprojects {
dependsOn(tasks.withType<PublishToMavenRepository>())
}
from(rootProject.layout.buildDirectory.dir("artifacts/maven"))
archiveFileName.set("bundle.zip")
destinationDirectory.set(layout.buildDirectory)
}
@Suppress("unused")
val publishMavenToCentralPortal by registering {
group = "publishing"
dependsOn(packSonatypeCentralBundle)
doLast {
val uriBase = "https://central.sonatype.com/api/v1/publisher/upload"
val mainBranch = System.getenv("BRANCH_KOOG_IS_RELEASING_FROM") == "main"
val publishingType = if (mainBranch) {
println("Publishing from the main branch, so publishing as AUTOMATIC.")
"AUTOMATIC"
} else {
println("Publishing from the non-main branch, so publishing as USER_MANAGED.")
"USER_MANAGED" // do not publish releases from non-main branches without approval
}
val deploymentName = "${project.name}-$version"
val uri = "$uriBase?name=$deploymentName&publishingType=$publishingType"
val userName = System.getenv("CE_MVN_CLIENT_USERNAME") as String
val token = System.getenv("CE_MVN_CLIENT_PASSWORD") as String
val base64Auth = Base64.getEncoder().encode("$userName:$token".toByteArray()).toString(Charsets.UTF_8)
val bundleFile = packSonatypeCentralBundle.get().archiveFile.get().asFile
println("Sending request to $uri...")
val client = OkHttpClient()
val request = Request.Builder()
.url(uri)
.header("Authorization", "Bearer $base64Auth")
.post(
MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("bundle", bundleFile.name, bundleFile.asRequestBody())
.build()
)
.build()
client.newCall(request).execute().use { response ->
val statusCode = response.code
println("Upload status code: $statusCode")
println("Upload result: ${response.body!!.string()}")
if (statusCode != 201) {
error("Upload error to Central repository. Status code $statusCode.")
}
}
}
}
}
dependencies {
dokka(project(":agents:agents-core"))
dokka(project(":agents:agents-features:agents-features-common"))
dokka(project(":agents:agents-features:agents-features-memory"))
dokka(project(":agents:agents-features:agents-features-opentelemetry"))
dokka(project(":agents:agents-features:agents-features-trace"))
dokka(project(":agents:agents-features:agents-features-tokenizer"))
dokka(project(":agents:agents-features:agents-features-event-handler"))
dokka(project(":agents:agents-features:agents-features-snapshot"))
dokka(project(":agents:agents-mcp"))
dokka(project(":agents:agents-test"))
dokka(project(":agents:agents-tools"))
dokka(project(":agents:agents-utils"))
dokka(project(":agents:agents-ext"))
dokka(project(":embeddings:embeddings-base"))
dokka(project(":embeddings:embeddings-llm"))
dokka(project(":prompt:prompt-cache:prompt-cache-files"))
dokka(project(":prompt:prompt-cache:prompt-cache-model"))
dokka(project(":prompt:prompt-cache:prompt-cache-redis"))
dokka(project(":prompt:prompt-executor:prompt-executor-cached"))
dokka(project(":prompt:prompt-executor:prompt-executor-clients"))
dokka(project(":prompt:prompt-executor:prompt-executor-clients:prompt-executor-anthropic-client"))
dokka(project(":prompt:prompt-executor:prompt-executor-clients:prompt-executor-google-client"))
dokka(project(":prompt:prompt-executor:prompt-executor-clients:prompt-executor-openai-client"))
dokka(project(":prompt:prompt-executor:prompt-executor-clients:prompt-executor-openrouter-client"))
dokka(project(":prompt:prompt-executor:prompt-executor-clients:prompt-executor-ollama-client"))
dokka(project(":prompt:prompt-executor:prompt-executor-clients:prompt-executor-bedrock-client"))
dokka(project(":prompt:prompt-executor:prompt-executor-llms"))
dokka(project(":prompt:prompt-executor:prompt-executor-llms-all"))
dokka(project(":prompt:prompt-executor:prompt-executor-model"))
dokka(project(":prompt:prompt-llm"))
dokka(project(":prompt:prompt-markdown"))
dokka(project(":prompt:prompt-model"))
dokka(project(":prompt:prompt-structure"))
dokka(project(":prompt:prompt-tokenizer"))
dokka(project(":prompt:prompt-xml"))
dokka(project(":koog-spring-boot-starter"))
dokka(project(":rag:rag-base"))
dokka(project(":rag:vector-storage"))
}
kover {
val excludedProjects = setOf(
":integration-tests",
":examples",
":buildSrc"
)
merge {
subprojects {
it.path !in excludedProjects
}
}
reports {
total {
binary {
file = file(".qodana/code-coverage/kover.ic")
}
}
}
}