Day01 2021
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user