-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
54 lines (43 loc) · 1.32 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
import de.undercouch.gradle.tasks.download.Download
plugins {
kotlin("jvm") version "2.0.20"
id("de.undercouch.download") version "5.0.0"
}
group = "com.berger-sandro"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("org.reflections:reflections:0.10.2")
implementation("org.jetbrains.kotlin:kotlin-reflect")
testImplementation(kotlin("test"))
}
kotlin {
jvmToolchain(21)
}
tasks.test {
useJUnitPlatform()
}
tasks.register<JavaExec>("run") {
group = "application"
description = "Run the main class"
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("com.bergersandro.AoC2024MainKt")
}
fun registerDownloadTask(day: Int, sessionCookie: String) {
tasks.register<Download>("downloadInputDay$day") {
description = "Download input file for Advent of Code Day $day"
val destFile = file("src/main/resources/input-files/data-day$day.txt")
onlyIf { !destFile.exists() }
dest(destFile)
onlyIfModified(true)
header("Cookie", "session=$sessionCookie")
src("https://adventofcode.com/2024/day/$day/input")
println("Downloaded input file for Day $day")
}
}
val adventOfCodeSessionCookie: String by project
(1..24).forEach { day ->
registerDownloadTask(day, adventOfCodeSessionCookie)
}