|
| 1 | +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar |
| 2 | +import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 3 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 4 | + |
| 5 | +plugins { |
| 6 | + kotlin("jvm") version "2.1.21" |
| 7 | + kotlin("kapt") version "2.1.21" |
| 8 | + kotlin("plugin.serialization") version "2.1.21" |
| 9 | + id("com.gradleup.shadow") version "8.3.9" |
| 10 | +} |
| 11 | + |
| 12 | +group = "org.jetbrains.ktor" |
| 13 | +version = "1.0-SNAPSHOT" |
| 14 | + |
| 15 | +val ktorVersion = "3.3.3" |
| 16 | +val serializationVersion = "1.8.1" |
| 17 | +val hikariVersion = "5.1.0" |
| 18 | +val logbackVersion = "1.5.13" |
| 19 | +val mysqlVersion = "8.0.33" |
| 20 | +val postgresqlVersion = "42.7.5" |
| 21 | +val jstachioVersion = "1.3.6" |
| 22 | + |
| 23 | +repositories { |
| 24 | + mavenCentral() |
| 25 | +} |
| 26 | + |
| 27 | +dependencies { |
| 28 | + implementation(kotlin("stdlib")) |
| 29 | + implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion") |
| 30 | + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion") |
| 31 | + |
| 32 | + implementation("io.ktor:ktor-server-default-headers-jvm:$ktorVersion") |
| 33 | + implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion") |
| 34 | + |
| 35 | + implementation("com.zaxxer:HikariCP:$hikariVersion") |
| 36 | + implementation("ch.qos.logback:logback-classic:$logbackVersion") |
| 37 | + |
| 38 | + implementation("org.postgresql:postgresql:$postgresqlVersion") |
| 39 | + implementation("mysql:mysql-connector-java:$mysqlVersion") |
| 40 | + |
| 41 | + implementation("io.jstach:jstachio:$jstachioVersion") |
| 42 | + kapt("io.jstach:jstachio-apt:$jstachioVersion") |
| 43 | +} |
| 44 | + |
| 45 | +kotlin { |
| 46 | + jvmToolchain(21) |
| 47 | +} |
| 48 | + |
| 49 | +tasks.withType<KotlinCompile>().configureEach { |
| 50 | + compilerOptions { |
| 51 | + jvmTarget.set(JvmTarget.JVM_21) |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +tasks.named<ShadowJar>("shadowJar") { |
| 56 | + enabled = false |
| 57 | +} |
| 58 | + |
| 59 | +fun registerBundle( |
| 60 | + name: String, |
| 61 | + classifier: String, |
| 62 | + mainClass: String, |
| 63 | + exclusions: List<String> |
| 64 | +) = tasks.register(name, ShadowJar::class) { |
| 65 | + archiveBaseName.set("tech-empower-framework-benchmark") |
| 66 | + archiveVersion.set(project.version.toString()) |
| 67 | + archiveClassifier.set(classifier) |
| 68 | + manifest { |
| 69 | + attributes["Main-Class"] = mainClass |
| 70 | + } |
| 71 | + from(sourceSets.main.get().output) |
| 72 | + configurations = listOf(project.configurations.runtimeClasspath.get()) |
| 73 | + dependencies { |
| 74 | + exclusions.forEach { exclude(dependency(it)) } |
| 75 | + } |
| 76 | + exclude("META-INF/*.SF") |
| 77 | + exclude("META-INF/*.DSA") |
| 78 | + exclude("META-INF/*.RSA") |
| 79 | + mergeServiceFiles() |
| 80 | +} |
| 81 | + |
| 82 | +val nettyBundle by registerBundle( |
| 83 | + name = "nettyBundle", |
| 84 | + classifier = "netty-bundle", |
| 85 | + mainClass = "io.ktor.server.netty.EngineMain", |
| 86 | + exclusions = emptyList() |
| 87 | +) |
| 88 | + |
| 89 | +tasks.named("build") { |
| 90 | + dependsOn(nettyBundle) |
| 91 | +} |
0 commit comments