1
0

Day01 2021

This commit is contained in:
2021-12-01 12:42:10 +01:00
parent ae327a4928
commit ccfcf5a259
7 changed files with 2062 additions and 6 deletions
@@ -10,7 +10,6 @@ import org.gradle.kotlin.dsl.getByType
open class AdventOfCodeExtension {
var session: String? = null
var year: Int = 2020
}
class AdventOfCodeDownloaderPlugin : Plugin<Project> {
@@ -26,8 +25,12 @@ class AdventOfCodeDownloaderPlugin : Plugin<Project> {
throw GradleException("advent of code session not set")
}
val now = LocalDateTime.now()
val year = now.year
val currentDay = now.dayOfMonth.toString()
val resourceDir: File = project
.project(":days")
.project(":$year")
.extensions
.getByType<SourceSetContainer>()
.getByName("main")
@@ -35,9 +38,9 @@ class AdventOfCodeDownloaderPlugin : Plugin<Project> {
.srcDirs
.first()
val currentDay = LocalDateTime.now().dayOfMonth.toString()
val outFile = File(resourceDir, "day" + currentDay.padStart(length = 2, padChar = '0') + ".txt")
val url = "https://adventofcode.com/${extension.year}/day/$currentDay/input"
val url = "https://adventofcode.com/$year/day/$currentDay/input"
Unirest.get(url)
.cookie("session", extension.session)