generated from kotlin-hands-on/advent-of-code-kotlin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
84 lines (74 loc) · 2.1 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
import kotlinx.benchmark.gradle.JvmBenchmarkTarget
import org.jetbrains.kotlin.allopen.gradle.AllOpenExtension
plugins {
kotlin("jvm") version "2.0.21"
kotlin("plugin.allopen") version "2.0.20"
id("org.jetbrains.kotlinx.benchmark") version "0.4.12"
id("org.graalvm.buildtools.native") version "0.10.3"
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.12")
}
configure<AllOpenExtension> {
annotation("org.openjdk.jmh.annotations.State")
}
sourceSets {
main {
kotlin.srcDir("src")
}
}
tasks {
wrapper {
gradleVersion = "8.11"
}
}
benchmark {
configurations {
named("main") {
iterationTime = 5
iterationTimeUnit = "sec"
}
register("Day16Speed") {
iterationTime = 5
iterationTimeUnit = "sec"
include("days.day16speed.Day16Benchmark")
}
}
targets {
register("main") {
this as JvmBenchmarkTarget
jmhVersion = "1.35"
}
}
}
// run with java -jar build/libs/advent-of-code-kotlin-2024-standalone.jar src/Day16.txt
tasks {
val fatJar = register<Jar>("fatJar") {
dependsOn.addAll(listOf("compileJava", "compileKotlin", "processResources")) // We need this for Gradle optimization to work
archiveClassifier.set("standalone") // Naming the jar
manifest {
attributes("Main-Class" to "days.day22speed.Day22Speed")
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
val sourcesMain = sourceSets.main.get()
val contents = configurations.runtimeClasspath.get()
.map { if (it.isDirectory) it else zipTree(it) } +
sourcesMain.output
from(contents)
}
build {
dependsOn(fatJar) // Trigger fat jar creation during build
}
}
// build with ./gradlew nativeCompile (first set jenv version to the Graal VM)
kotlin {
jvmToolchain(21)
}
graalvmNative {
toolchainDetection.set(true)
binaries {
named("main") {
mainClass.set("days.day22speed.Day22Speed")
}
}
}