-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
65 lines (53 loc) · 2.17 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
import org.gradle.internal.os.OperatingSystem
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
plugins {
kotlin("jvm") version "1.9.23"
id("io.ktor.plugin") version "2.3.9"
}
group = "com.frazieje"
version = "0.0.1"
application {
mainClass.set("com.frazieje.findinpi.ApplicationKt")
val isDevelopment: Boolean = project.ext.has("development")
val nativeBuild = file(project.layout.buildDirectory.dir("native")).absolutePath
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment", "-Djava.library.path=$nativeBuild")
}
val nativeBuildDir = project.layout.buildDirectory.dir("native").get().asFile
val nativeSourceDir = project.layout.projectDirectory.dir("src/main/jni").asFile
val generateNativeBuildSystemTask = tasks.create<Exec>("generateNativeBuildSystem") {
dependsOn(tasks.getByName("compileJava"))
// val platform = if (OperatingSystem.current().isLinux) {
// "linux"
// } else if (OperatingSystem.current().isMacOsX) {
// "darwin"
// } else {
// "windows"
// }
workingDir = nativeSourceDir
commandLine = listOf("cmake", "-S", ".", "-B", nativeBuildDir.absolutePath, "-DNATIVE_BUILD_DIR=${nativeBuildDir.absolutePath}")
}
val buildNativeTask = tasks.create<Exec>("buildNative") {
dependsOn(generateNativeBuildSystemTask)
workingDir = nativeSourceDir
commandLine = listOf("cmake", "--build", nativeBuildDir.absolutePath, "--target", "all")
}
tasks.getByName("classes").dependsOn(buildNativeTask)
tasks.withType<JavaCompile> {
val compilerArgs = options.compilerArgs
compilerArgs.add("-h")
compilerArgs.add(nativeBuildDir.absolutePath)
}
repositories {
mavenCentral()
}
dependencies {
implementation("io.ktor:ktor-server-core-jvm")
implementation("io.ktor:ktor-server-netty-jvm")
implementation("io.ktor:ktor-server-content-negotiation-jvm")
implementation("io.ktor:ktor-serialization-gson-jvm")
implementation("ch.qos.logback:logback-classic:$logback_version")
testImplementation("io.ktor:ktor-server-tests-jvm")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
}