114 lines
3.4 KiB
Kotlin
114 lines
3.4 KiB
Kotlin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||
import org.gradle.api.tasks.testing.logging.TestLogEvent.*
|
||
|
||
plugins {
|
||
java
|
||
application
|
||
id("com.gradleup.shadow") version "9.2.2"
|
||
}
|
||
|
||
group = "com.example"
|
||
version = "1.0.0-SNAPSHOT"
|
||
|
||
repositories {
|
||
mavenCentral()
|
||
}
|
||
|
||
val vertxVersion = "5.0.10"
|
||
|
||
val mainVerticleName = "su.xserver.iikocon.MainVerticle"
|
||
val launcherClassName = "io.vertx.launcher.application.VertxApplication"
|
||
|
||
application {
|
||
mainClass.set(launcherClassName)
|
||
}
|
||
|
||
dependencies {
|
||
implementation(platform("io.vertx:vertx-stack-depchain:$vertxVersion"))
|
||
implementation("io.vertx:vertx-launcher-application")
|
||
implementation("io.vertx:vertx-web-client")
|
||
implementation("io.vertx:vertx-config")
|
||
implementation("io.vertx:vertx-sql-client-templates")
|
||
implementation("io.vertx:vertx-health-check")
|
||
implementation("io.vertx:vertx-web")
|
||
implementation("io.vertx:vertx-mysql-client")
|
||
implementation("io.vertx:vertx-redis-client")
|
||
implementation("io.vertx:vertx-web-sstore-redis")
|
||
implementation("io.vertx:vertx-mail-client")
|
||
|
||
implementation("com.fasterxml.jackson.core:jackson-databind")
|
||
|
||
// https://mvnrepository.com/artifact/org.mindrot/jbcrypt
|
||
implementation("org.mindrot:jbcrypt:0.4")
|
||
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
|
||
implementation("org.slf4j:slf4j-api:2.0.17")
|
||
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j2-impl
|
||
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.25.3")
|
||
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
|
||
implementation("org.apache.logging.log4j:log4j-core:2.25.3")
|
||
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api
|
||
implementation("org.apache.logging.log4j:log4j-api:2.25.3")
|
||
|
||
}
|
||
|
||
java {
|
||
sourceCompatibility = JavaVersion.VERSION_21
|
||
targetCompatibility = JavaVersion.VERSION_21
|
||
}
|
||
|
||
tasks.withType<ShadowJar> {
|
||
archiveClassifier.set("fat")
|
||
manifest {
|
||
attributes(mapOf("Main-Verticle" to mainVerticleName))
|
||
}
|
||
mergeServiceFiles()
|
||
}
|
||
|
||
tasks.withType<Test> {
|
||
useJUnitPlatform()
|
||
testLogging {
|
||
events = setOf(PASSED, SKIPPED, FAILED)
|
||
}
|
||
}
|
||
|
||
tasks.withType<JavaExec> {
|
||
args = listOf(mainVerticleName)
|
||
}
|
||
|
||
tasks.register("collectAllDependencies") {
|
||
group = "project"
|
||
description = "Сбор всех зависимостей для офлайн работы"
|
||
|
||
doLast {
|
||
val outDir = File("${rootDir}/libs")
|
||
outDir.mkdirs()
|
||
|
||
val allArtifacts = configurations
|
||
.filter { it.isCanBeResolved }
|
||
.flatMap { config ->
|
||
config.resolvedConfiguration.lenientConfiguration.allModuleDependencies.flatMap { dep ->
|
||
dep.allModuleArtifacts
|
||
}
|
||
}
|
||
// ❗ Исключаем артефакты локальных проектов (например, :library)
|
||
.filterNot { artifact ->
|
||
artifact.id.componentIdentifier.displayName.startsWith("project ")
|
||
}
|
||
.distinctBy { it.file.name }
|
||
|
||
allArtifacts.forEach { artifact ->
|
||
val outFile = outDir.resolve(artifact.file.name)
|
||
if (!outFile.exists() && artifact.file.exists()) {
|
||
println("⬇️ Copying ${artifact.moduleVersion.id.group}:${artifact.name}:${artifact.moduleVersion.id.version} ...")
|
||
artifact.file.inputStream().use { input ->
|
||
outFile.outputStream().use { output ->
|
||
input.copyTo(output)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
println("✅ All dependencies are collected in \"libs\"")
|
||
}
|
||
}
|
||
|