-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
188 lines (161 loc) · 5.44 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
180
181
182
183
184
185
186
187
188
// SPDX-FileCopyrightText: 2024 Deutsche Telekom AG
//
// SPDX-License-Identifier: Apache-2.0
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.BufferedReader
import java.io.InputStreamReader
import java.lang.System.getenv
import java.net.URI
plugins {
kotlin("jvm") version "2.0.21" apply false
kotlin("plugin.serialization") version "1.9.23" apply false
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("org.jetbrains.kotlinx.kover") version "0.8.3"
id("org.jetbrains.dokka") version "1.9.20"
id("org.cyclonedx.bom") version "1.8.2" apply false
id("net.researchgate.release") version "3.0.2"
id("com.vanniktech.maven.publish") version "0.30.0"
}
val springBootVersion by extra { "3.3.5" }
subprojects {
group = "org.eclipse.lmos"
apply(plugin = "kotlin")
apply(plugin = "kotlinx-serialization")
apply(plugin = "org.cyclonedx.bom")
apply(plugin = "org.jetbrains.kotlinx.kover")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "com.vanniktech.maven.publish")
version = rootProject.version
repositories {
mavenLocal()
mavenCentral()
maven { setUrl("https://repo.spring.io/milestone") }
maven { setUrl("https://repo.spring.io/snapshot") }
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
freeCompilerArgs += "-Xcontext-receivers"
jvmTarget = "21"
}
}
java {
sourceCompatibility = JavaVersion.VERSION_21
}
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}
dependencies {
"testImplementation"("org.junit.jupiter:junit-jupiter:5.11.3")
"testImplementation"("org.assertj:assertj-core:3.26.3")
"testImplementation"("io.mockk:mockk:1.13.13")
}
tasks.named("dokkaJavadoc") {
mustRunAfter("checksum")
}
tasks.withType<Test> {
val runFlowTests = project.findProperty("runFlowTests")?.toString()?.toBoolean() ?: false
if (!runFlowTests) {
exclude("**/*Flow*")
}
useJUnitPlatform()
}
mavenPublishing {
publishToMavenCentral(SonatypeHost.DEFAULT)
signAllPublications()
pom {
name = "LMOS Router"
description = "Efficient Agent Routing with SOTA Language and Embedding Models."
url = "https://github.com/eclipse-lmos/lmos-router"
licenses {
license {
name = "Apache-2.0"
distribution = "repo"
url = "https://github.com/eclipse-lmos/lmos-router/blob/main/LICENSES/Apache-2.0.txt"
}
}
developers {
developer {
id = "xmxnt"
name = "Amant Kumar"
email = "[email protected]"
}
developer {
id = "jas34"
name = "Jasbir Singh"
email = "[email protected]"
}
developer {
id = "merrenfx"
name = "Max Erren"
email = "[email protected]"
}
}
scm {
url = "https://github.com/eclipse-lmos/lmos-router.git"
}
}
repositories {
maven {
name = "GitHubPackages"
url = URI("https://maven.pkg.github.com/eclipse-lmos/lmos-router")
credentials {
username = findProperty("GITHUB_USER")?.toString() ?: getenv("GITHUB_USER")
password = findProperty("GITHUB_TOKEN")?.toString() ?: getenv("GITHUB_TOKEN")
}
}
}
}
}
repositories {
mavenLocal()
mavenCentral()
}
fun Project.java(configure: Action<JavaPluginExtension>): Unit = (this as ExtensionAware).extensions.configure("java", configure)
fun String.execWithCode(workingDir: File? = null): Pair<CommandResult, Sequence<String>> {
ProcessBuilder().apply {
workingDir?.let { directory(it) }
command(split(" "))
redirectErrorStream(true)
val process = start()
val result = process.readStream()
val code = process.waitFor()
return CommandResult(code) to result
}
}
class CommandResult(val code: Int) {
val isFailed = code != 0
val isSuccess = !isFailed
fun ifFailed(block: () -> Unit) {
if (isFailed) block()
}
}
fun Project.isBOM() = name.endsWith("-bom")
private fun Process.readStream() =
sequence<String> {
val reader = BufferedReader(InputStreamReader(inputStream))
try {
var line: String?
while (true) {
line = reader.readLine()
if (line == null) {
break
}
yield(line)
}
} finally {
reader.close()
}
}
release {
buildTasks = listOf("releaseBuild")
newVersionCommitMessage = "New Snapshot-Version:"
preTagCommitMessage = "Release:"
}
tasks.register("releaseBuild") {
dependsOn(subprojects.mapNotNull { it.tasks.findByName("build") })
}